From 22eb51447d4eaa9b4e68a4678cd699029e65cfe1 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 30 Aug 2020 17:26:18 +0200 Subject: [PATCH] Adapt 2FA changes to glitch-soc's theming system --- .../webauthn_credentials_controller.rb | 4 ++++ app/javascript/core/auth.js | 2 ++ app/javascript/core/theme.yml | 2 +- app/javascript/{packs => core}/two_factor_authentication.js | 0 app/views/auth/sessions/two_factor.html.haml | 2 -- .../webauthn_credentials/new.html.haml | 2 -- 6 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 app/javascript/core/auth.js rename app/javascript/{packs => core}/two_factor_authentication.js (100%) diff --git a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb index a19c604f3b..ee53927851 100644 --- a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb +++ b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb @@ -85,6 +85,10 @@ module Settings private + def set_pack + use_pack 'auth' + end + def require_otp_enabled unless current_user.otp_enabled? flash[:error] = t('webauthn_credentials.otp_required') diff --git a/app/javascript/core/auth.js b/app/javascript/core/auth.js new file mode 100644 index 0000000000..ca04730a3a --- /dev/null +++ b/app/javascript/core/auth.js @@ -0,0 +1,2 @@ +import './settings'; +import './two_factor_authentication'; diff --git a/app/javascript/core/theme.yml b/app/javascript/core/theme.yml index dc641772c5..b9144e43aa 100644 --- a/app/javascript/core/theme.yml +++ b/app/javascript/core/theme.yml @@ -3,7 +3,7 @@ pack: about: admin: admin.js - auth: settings.js + auth: auth.js common: filename: common.js stylesheet: true diff --git a/app/javascript/packs/two_factor_authentication.js b/app/javascript/core/two_factor_authentication.js similarity index 100% rename from app/javascript/packs/two_factor_authentication.js rename to app/javascript/core/two_factor_authentication.js diff --git a/app/views/auth/sessions/two_factor.html.haml b/app/views/auth/sessions/two_factor.html.haml index f2f6fe19d5..1867ec7f8a 100644 --- a/app/views/auth/sessions/two_factor.html.haml +++ b/app/views/auth/sessions/two_factor.html.haml @@ -1,8 +1,6 @@ - content_for :page_title do = t('auth.login') -=javascript_pack_tag 'two_factor_authentication', integrity: true, crossorigin: 'anonymous' - - if @webauthn_enabled = render partial: 'auth/sessions/two_factor/webauthn_form', locals: { hidden: @scheme_type != 'webauthn' } diff --git a/app/views/settings/two_factor_authentication/webauthn_credentials/new.html.haml b/app/views/settings/two_factor_authentication/webauthn_credentials/new.html.haml index 0b23bb6897..c5a323ee50 100644 --- a/app/views/settings/two_factor_authentication/webauthn_credentials/new.html.haml +++ b/app/views/settings/two_factor_authentication/webauthn_credentials/new.html.haml @@ -12,5 +12,3 @@ .actions = f.button :button, t('webauthn_credentials.add'), class: 'js-webauthn', type: :submit - -= javascript_pack_tag 'two_factor_authentication', integrity: true, crossorigin: 'anonymous'