Skip to content

Commit 6e325fa

Browse files
committed
fix: requirement for email_confirmed in backend
1 parent 38a6793 commit 6e325fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/backend/src/api/APIError.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ module.exports = class APIError {
470470
},
471471
'email_must_be_confirmed': {
472472
status: 422,
473-
message: 'Email must be confirmed to apply a share.',
473+
message: ({action}) =>
474+
`Email must be confirmed to ${action ?? 'apply a share'}.`,
474475
},
475476
'no_need_to_request': {
476477
status: 422,

src/backend/src/routers/auth/configure-2fa.js

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ module.exports = eggspress('/auth/configure-2fa/:action', {
105105
}
106106

107107
const user = await get_user({ id: req.user.id, force: true });
108+
109+
if ( ! user.email_confirmed ) {
110+
throw APIError.create('email_must_be_confirmed', null, {
111+
action: 'enable 2FA'
112+
});
113+
}
108114

109115
// Verify that 2FA isn't already enabled
110116
if ( user.otp_enabled ) {

0 commit comments

Comments
 (0)