2020-04-01 20:32:24 +00:00
|
|
|
import { settings } from '@rocket.chat/sdk';
|
|
|
|
|
|
|
|
import { TWO_FACTOR } from '../containers/TwoFactor';
|
2021-09-13 20:41:05 +00:00
|
|
|
import EventEmitter from './events';
|
2020-04-01 20:32:24 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
export const twoFactor = ({ method, invalid }) =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
EventEmitter.emit(TWO_FACTOR, {
|
|
|
|
method,
|
|
|
|
invalid,
|
|
|
|
cancel: () => reject(),
|
|
|
|
submit: code => {
|
|
|
|
settings.customHeaders = {
|
|
|
|
...settings.customHeaders,
|
|
|
|
'x-2fa-code': code,
|
|
|
|
'x-2fa-method': method
|
|
|
|
};
|
|
|
|
resolve({ twoFactorCode: code, twoFactorMethod: method });
|
|
|
|
}
|
|
|
|
});
|
2020-04-01 20:32:24 +00:00
|
|
|
});
|