mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 22:40:20 +08:00
fix: requirement for email_confirmed in backend
This commit is contained in:
parent
38a6793c16
commit
6e325fa000
@ -470,7 +470,8 @@ module.exports = class APIError {
|
|||||||
},
|
},
|
||||||
'email_must_be_confirmed': {
|
'email_must_be_confirmed': {
|
||||||
status: 422,
|
status: 422,
|
||||||
message: 'Email must be confirmed to apply a share.',
|
message: ({action}) =>
|
||||||
|
`Email must be confirmed to ${action ?? 'apply a share'}.`,
|
||||||
},
|
},
|
||||||
'no_need_to_request': {
|
'no_need_to_request': {
|
||||||
status: 422,
|
status: 422,
|
||||||
|
@ -106,6 +106,12 @@ module.exports = eggspress('/auth/configure-2fa/:action', {
|
|||||||
|
|
||||||
const user = await get_user({ id: req.user.id, force: true });
|
const user = await get_user({ id: req.user.id, force: true });
|
||||||
|
|
||||||
|
if ( ! user.email_confirmed ) {
|
||||||
|
throw APIError.create('email_must_be_confirmed', null, {
|
||||||
|
action: 'enable 2FA'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Verify that 2FA isn't already enabled
|
// Verify that 2FA isn't already enabled
|
||||||
if ( user.otp_enabled ) {
|
if ( user.otp_enabled ) {
|
||||||
throw APIError.create('2fa_already_enabled');
|
throw APIError.create('2fa_already_enabled');
|
||||||
|
Loading…
Reference in New Issue
Block a user