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/enable.js

23 lines
485 B

import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';
Meteor.methods({
'2fa:enable'() {
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
const user = Meteor.user();
const secret = TOTP.generateSecret();
Users.disable2FAAndSetTempSecretByUserId(Meteor.userId(), secret.base32);
return {
secret: secret.base32,
url: TOTP.generateOtpauthURL(secret, user.username),
};
},
});