Skip to content

Commit

Permalink
implement new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Jul 30, 2024
1 parent 39fb14e commit 214015c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apps/meteor/app/2fa/server/code/EmailCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class EmailCheck implements ICodeCheck {
return false;
}

if (settings.get('Accounts_TwoFactorAuthentication_Disable_Email_For_OAuth_Users')) {
return user?.services?.password?.bcrypt !== undefined;
}

return this.getUserVerifiedEmails(user).length > 0;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class PasswordCheckFallback implements ICodeCheck {
// TODO: Remove this setting for version 4.0 forcing the
// password fallback for who has password set.
if (settings.get('Accounts_TwoFactorAuthentication_Enforce_Password_Fallback')) {
return user.services?.password?.bcrypt != null;
return user.services?.password?.bcrypt !== undefined;
}
return false;
}
Expand Down
12 changes: 12 additions & 0 deletions apps/meteor/server/settings/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export const createAccountSettings = () =>
public: true,
});

await this.add('Accounts_TwoFactorAuthentication_Disable_Email_For_OAuth_Users', false, {
type: 'boolean',
enableQuery: [
enable2FA,
{
_id: 'Accounts_TwoFactorAuthentication_By_Email_Enabled',
value: true,
},
],
public: true,
});

await this.add('Accounts_TwoFactorAuthentication_By_Email_Auto_Opt_In', true, {
type: 'boolean',
enableQuery: [
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
"Accounts_TwoFactorAuthentication_By_Email_Code_Expiration": "Time to expire the code sent via email in seconds",
"Accounts_TwoFactorAuthentication_By_Email_Enabled": "Enable Two Factor Authentication via Email",
"Accounts_TwoFactorAuthentication_By_Email_Enabled_Description": "Users with email verified and the option enabled in their profile page will receive an email with a temporary code to authorize certain actions like login, save the profile, etc.",
"Accounts_TwoFactorAuthentication_Disable_Email_For_OAuth_Users": "Disable two factor authentication via email for OAuth users",
"Accounts_TwoFactorAuthentication_Enabled": "Enable Two Factor Authentication",
"Accounts_TwoFactorAuthentication_Enabled_Description": "If deactivated, this setting will deactivate all Two Factor Authentication. \nTo force users to use Two Factor Authentication, the admin has to configure the 'user' role to enforce it.",
"Accounts_TwoFactorAuthentication_Enforce_Password_Fallback": "Enforce password fallback",
Expand Down

0 comments on commit 214015c

Please sign in to comment.