diff options
Diffstat (limited to 'app/assets/javascripts/authentication/two_factor_auth/index.js')
-rw-r--r-- | app/assets/javascripts/authentication/two_factor_auth/index.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/assets/javascripts/authentication/two_factor_auth/index.js b/app/assets/javascripts/authentication/two_factor_auth/index.js new file mode 100644 index 00000000000..5e59c44e8cd --- /dev/null +++ b/app/assets/javascripts/authentication/two_factor_auth/index.js @@ -0,0 +1,46 @@ +import Vue from 'vue'; +import { updateHistory, removeParams } from '~/lib/utils/url_utility'; +import RecoveryCodes from './components/recovery_codes.vue'; +import { SUCCESS_QUERY_PARAM } from './constants'; + +export const initRecoveryCodes = () => { + const el = document.querySelector('.js-2fa-recovery-codes'); + + if (!el) { + return false; + } + + const { codes = '[]', profileAccountPath = '' } = el.dataset; + + return new Vue({ + el, + render(createElement) { + return createElement(RecoveryCodes, { + props: { + codes: JSON.parse(codes), + profileAccountPath, + }, + }); + }, + }); +}; + +export const initClose2faSuccessMessage = () => { + const closeButton = document.querySelector('.js-close-2fa-enabled-success-alert'); + + if (!closeButton) { + return; + } + + closeButton.addEventListener( + 'click', + () => { + updateHistory({ + url: removeParams([SUCCESS_QUERY_PARAM]), + title: document.title, + replace: true, + }); + }, + { once: true }, + ); +}; |