The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/2fa/server/methods/disable.js

27 lines
539 B

import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';
Meteor.methods({
'2fa:disable'(code) {
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
const user = Meteor.user();
const verified = TOTP.verify({
secret: user.services.totp.secret,
token: code,
userId: Meteor.userId(),
backupTokens: user.services.totp.hashedBackup,
});
if (!verified) {
return false;
}
return Users.disable2FAByUserId(Meteor.userId());
},
});