Skip to content

Commit

Permalink
preauth and authenticate now also return the email address of the user
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Sep 26, 2024
1 parent 21a05ad commit 25fd1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/user-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25fd1b9

Please sign in to comment.