debian-mirror-gitlab/app/assets/javascripts/authentication/mount_2fa.js

24 lines
621 B
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import $ from 'jquery';
import initU2F from './u2f';
2020-11-24 15:15:51 +05:30
import initWebauthn from './webauthn';
2020-06-23 00:09:42 +05:30
import U2FRegister from './u2f/register';
2020-11-24 15:15:51 +05:30
import WebAuthnRegister from './webauthn/register';
2020-06-23 00:09:42 +05:30
export const mount2faAuthentication = () => {
2020-11-24 15:15:51 +05:30
if (gon.webauthn) {
initWebauthn();
} else {
initU2F();
}
2020-06-23 00:09:42 +05:30
};
export const mount2faRegistration = () => {
2020-11-24 15:15:51 +05:30
if (gon.webauthn) {
const webauthnRegister = new WebAuthnRegister($('#js-register-token-2fa'), gon.webauthn);
webauthnRegister.start();
} else {
const u2fRegister = new U2FRegister($('#js-register-token-2fa'), gon.u2f);
u2fRegister.start();
}
2020-06-23 00:09:42 +05:30
};