Skip to content

Commit

Permalink
[FIX] Bypassing 2FA on email verification (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp authored Feb 14, 2023
1 parent 87f116b commit d108690
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion apps/meteor/app/2fa/server/loginHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ Accounts.registerLoginHandler('totp', function (options) {
callbacks.add(
'onValidateLogin',
(login) => {
if (login.type === 'resume' || login.type === 'proxy' || login.methodName === 'verifyEmail') {
if (login.methodName === 'verifyEmail') {
throw new Meteor.Error('verify-email', 'E-mail verified');
}

if (login.type === 'resume' || login.type === 'proxy') {
return login;
}
// CAS login doesn't yet support 2FA.
Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/ui/client/lib/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { Accounts } from 'meteor/accounts-base';
import { t } from '../../../utils';
import { dispatchToastMessage } from '../../../../client/lib/toast';

Accounts.onEmailVerificationLink(function (token, done) {
Accounts.onEmailVerificationLink(function (token) {
Accounts.verifyEmail(token, function (error) {
if (error == null) {
if (error.error === 'verify-email') {
dispatchToastMessage({ type: 'success', message: t('Email_verified') });
Meteor.call('afterVerifyEmail');
} else {
dispatchToastMessage({ type: 'error', message: error.message });
}
return done();
});
});

0 comments on commit d108690

Please sign in to comment.