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

30 lines
651 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 = () => {
2021-02-22 17:27:13 +05:30
const el = $('#js-register-token-2fa');
if (!el.length) {
return;
}
2020-11-24 15:15:51 +05:30
if (gon.webauthn) {
2021-02-22 17:27:13 +05:30
const webauthnRegister = new WebAuthnRegister(el, gon.webauthn);
2020-11-24 15:15:51 +05:30
webauthnRegister.start();
} else {
2021-02-22 17:27:13 +05:30
const u2fRegister = new U2FRegister(el, gon.u2f);
2020-11-24 15:15:51 +05:30
u2fRegister.start();
}
2020-06-23 00:09:42 +05:30
};