profile: hasPasskey

This commit is contained in:
Girish Ramakrishnan
2026-03-16 17:20:22 +05:30
parent 1c8aa7440c
commit 67500a7689
5 changed files with 14 additions and 49 deletions
+3 -12
View File
@@ -26,6 +26,8 @@ async function canEditProfile(req, res, next) {
async function get(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
const userPasskeys = await passkeys.listByUserId(req.user.id);
next(new HttpSuccess(200, {
id: req.user.id,
username: req.user.username,
@@ -33,6 +35,7 @@ async function get(req, res, next) {
fallbackEmail: req.user.fallbackEmail,
displayName: req.user.displayName,
totpEnabled: req.user.totpEnabled,
hasPasskey: userPasskeys.length > 0,
role: req.user.role,
source: req.user.source,
hasBackgroundImage: req.user.hasBackgroundImage,
@@ -232,17 +235,6 @@ async function destroyUserSession(req, res, next) {
next(new HttpSuccess(204));
}
async function getPasskey(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
const [error, result] = await safe(passkeys.listByUserId(req.user.id));
if (error) return next(BoxError.toHttpError(error));
// Only one passkey per user - return first one or null
const passkey = result.length > 0 ? passkeys.removePrivateFields(result[0]) : null;
next(new HttpSuccess(200, { passkey }));
}
async function getPasskeyRegistrationOptions(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
@@ -301,7 +293,6 @@ export default {
disableTotp,
setNotificationConfig,
destroyUserSession,
getPasskey,
getPasskeyRegistrationOptions,
registerPasskey,
deletePasskey