From 25fd1b9541a8320f2b0eb75df33366e43fae1d62 Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Thu, 26 Sep 2024 14:42:58 +0300 Subject: [PATCH] preauth and authenticate now also return the email address of the user --- lib/api/auth.js | 4 ++++ lib/user-handler.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/api/auth.js b/lib/api/auth.js index 08571960..5677eaf6 100644 --- a/lib/api/auth.js +++ b/lib/api/auth.js @@ -37,6 +37,7 @@ module.exports = (db, server, userHandler) => { success: successRes, id: userId, username: Joi.string().required().description('Username of authenticated User'), + address: Joi.string().required().description('Default email address of authenticated User'), scope: Joi.string().required().description('The scope this authentication is valid for'), require2fa: Joi.array().items(Joi.string()).required().description('List of enabled 2FA mechanisms') }) @@ -109,6 +110,7 @@ module.exports = (db, server, userHandler) => { success: true, id: authData.user.toString(), username: authData.username, + address: authData.address, scope: authData.scope, require2fa: authData.require2fa }; @@ -158,6 +160,7 @@ module.exports = (db, server, userHandler) => { success: successRes, id: userId, username: Joi.string().required().description('Username of authenticated User'), + address: Joi.string().required().description('Default email address of authenticated User'), scope: Joi.string().required().description('The scope this authentication is valid for'), require2fa: Joi.array().items(Joi.string()).required().description('List of enabled 2FA mechanisms'), requirePasswordChange: booleanSchema.required().description('Indicates if account hassword has been reset and should be replaced'), @@ -246,6 +249,7 @@ module.exports = (db, server, userHandler) => { success: true, id: authData.user.toString(), username: authData.username, + address: authData.address, scope: authData.scope, require2fa: authData.require2fa, requirePasswordChange: authData.requirePasswordChange diff --git a/lib/user-handler.js b/lib/user-handler.js index e1df616f..7db82ae5 100644 --- a/lib/user-handler.js +++ b/lib/user-handler.js @@ -853,6 +853,7 @@ class UserHandler { user: userData._id, username: userData.username, scope: meta.requiredScope, + address: userData.address, // if 2FA is enabled then require token validation require2fa: enabled2fa.length && !usingTemporaryPassword ? enabled2fa : false, requirePasswordChange // true, if password was reset and using temporary password @@ -1105,6 +1106,7 @@ class UserHandler { let authResponse = { user: userData._id, username: userData.username, + address: userData.address, scope: requiredScope, // if 2FA is enabled then require token validation require2fa: requiredScope === 'master' && enabled2fa.length ? enabled2fa : false