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/client/TOTPCrowd.js

36 lines
876 B

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import '../../crowd/client/index';
import { reportError } from '../../../client/lib/2fa/utils';
import { overrideLoginMethod } from '../../../client/lib/2fa/overrideLoginMethod';
Meteor.loginWithCrowdAndTOTP = function(username, password, code, callback) {
const loginRequest = {
crowd: true,
username,
crowdPassword: password,
};
Accounts.callLoginMethod({
methodArguments: [{
totp: {
login: loginRequest,
code,
},
}],
userCallback(error) {
if (error) {
reportError(error, callback);
} else {
callback && callback();
}
},
});
};
const { loginWithCrowd } = Meteor;
Meteor.loginWithCrowd = function(username, password, callback) {
overrideLoginMethod(loginWithCrowd, [username, password], callback, Meteor.loginWithCrowdAndTOTP);
};