summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/authentication/mount_2fa.js
blob: dd5a42fa5fcd3e0e883c566ea94866a70d7f0705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import $ from 'jquery';
import initU2F from './u2f';
import initWebauthn from './webauthn';
import U2FRegister from './u2f/register';
import WebAuthnRegister from './webauthn/register';

export const mount2faAuthentication = () => {
  if (gon.webauthn) {
    initWebauthn();
  } else {
    initU2F();
  }
};

export const mount2faRegistration = () => {
  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();
  }
};