diff options
Diffstat (limited to 'app/assets/javascripts/pages/sessions')
3 files changed, 12 insertions, 12 deletions
diff --git a/app/assets/javascripts/pages/sessions/index.js b/app/assets/javascripts/pages/sessions/index.js index c2c069d1ca8..e93def5323f 100644 --- a/app/assets/javascripts/pages/sessions/index.js +++ b/app/assets/javascripts/pages/sessions/index.js @@ -1,3 +1,3 @@ -import initU2F from '../../shared/sessions/u2f'; +import { mount2faAuthentication } from '~/authentication/mount_2fa'; -document.addEventListener('DOMContentLoaded', initU2F); +document.addEventListener('DOMContentLoaded', mount2faAuthentication); diff --git a/app/assets/javascripts/pages/sessions/new/oauth_remember_me.js b/app/assets/javascripts/pages/sessions/new/oauth_remember_me.js index 191221a48cd..8d2d5d41f6a 100644 --- a/app/assets/javascripts/pages/sessions/new/oauth_remember_me.js +++ b/app/assets/javascripts/pages/sessions/new/oauth_remember_me.js @@ -5,13 +5,12 @@ import { mergeUrlParams, removeParams } from '~/lib/utils/url_utility'; * OAuth-based login buttons have a separate "remember me" checkbox. * * Toggling this checkbox adds/removes a `remember_me` parameter to the - * login buttons' href, which is passed on to the omniauth callback. + * login buttons' parent form action, which is passed on to the omniauth callback. */ export default class OAuthRememberMe { constructor(opts = {}) { this.container = opts.container || ''; - this.loginLinkSelector = '.oauth-login'; } bindEvents() { @@ -22,12 +21,13 @@ export default class OAuthRememberMe { const rememberMe = $(event.target).is(':checked'); $('.oauth-login', this.container).each((i, element) => { - const href = $(element).attr('href'); + const $form = $(element).parent('form'); + const href = $form.attr('action'); if (rememberMe) { - $(element).attr('href', mergeUrlParams({ remember_me: 1 }, href)); + $form.attr('action', mergeUrlParams({ remember_me: 1 }, href)); } else { - $(element).attr('href', removeParams(['remember_me'], href)); + $form.attr('action', removeParams(['remember_me'], href)); } }); } diff --git a/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js b/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js index e617fecaa0f..1d47a9aed47 100644 --- a/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js +++ b/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js @@ -12,7 +12,7 @@ export default function preserveUrlFragment(fragment = '') { // Append the fragment to all sign-in/sign-up form actions so it is preserved when the user is // eventually redirected back to the originally requested URL. - const forms = document.querySelectorAll('#signin-container form'); + const forms = document.querySelectorAll('#signin-container .tab-content form'); Array.prototype.forEach.call(forms, form => { const actionWithFragment = setUrlFragment(form.getAttribute('action'), `#${normalFragment}`); form.setAttribute('action', actionWithFragment); @@ -20,13 +20,13 @@ export default function preserveUrlFragment(fragment = '') { // Append a redirect_fragment query param to all oauth provider links. The redirect_fragment // query param will be available in the omniauth callback upon successful authentication - const anchors = document.querySelectorAll('#signin-container a.oauth-login'); - Array.prototype.forEach.call(anchors, anchor => { + const oauthForms = document.querySelectorAll('#signin-container .omniauth-container form'); + Array.prototype.forEach.call(oauthForms, oauthForm => { const newHref = mergeUrlParams( { redirect_fragment: normalFragment }, - anchor.getAttribute('href'), + oauthForm.getAttribute('action'), ); - anchor.setAttribute('href', newHref); + oauthForm.setAttribute('action', newHref); }); } } |