diff --git a/app/assets/javascripts/users/login_disclaimer.js b/app/assets/javascripts/users/login_disclaimer.js new file mode 100644 index 000000000..4a287d4b9 --- /dev/null +++ b/app/assets/javascripts/users/login_disclaimer.js @@ -0,0 +1,17 @@ +(function() { + const modal = '#loginDisclaimerModal'; + + function initDisclaimer(button, form) { + $(button).on('click', function(e) { + e.preventDefault(); + $(modal).modal('show'); + $(modal).find('[data-action="submit"]').off('click').one('click', function() { + $(form).submit(); + }); + }); + } + + initDisclaimer('.log-in-button', '#new_user'); + initDisclaimer('.btn-okta', '#oktaForm'); + initDisclaimer('.btn-azure-ad', '.azureAdForm'); +}()); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2789e1c84..a12095fa1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,4 +258,9 @@ module ApplicationHelper qr_code_url = ROTP::TOTP.new(user.otp_secret, issuer: 'SciNote').provisioning_uri(user.email) RQRCode::QRCode.new(qr_code_url).as_svg(module_size: 4) end + + def login_disclaimer + # login_disclaimer: { title: "...", body: "...", action: "..." } + ApplicationSettings.instance.values['login_disclaimer'] + end end diff --git a/app/views/users/sessions/_login_disclaimer.html.erb b/app/views/users/sessions/_login_disclaimer.html.erb new file mode 100644 index 000000000..8cbd86440 --- /dev/null +++ b/app/views/users/sessions/_login_disclaimer.html.erb @@ -0,0 +1,22 @@ +<% if login_disclaimer %> + + <%= javascript_include_tag "users/login_disclaimer" %> +<% end %> diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index bd4e7879b..e9951ad4b 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -46,3 +46,5 @@ + +<%= render partial: 'login_disclaimer'%> diff --git a/app/views/users/shared/_azure_sign_in_links.html.erb b/app/views/users/shared/_azure_sign_in_links.html.erb index e9fb9b463..5a2b59d56 100644 --- a/app/views/users/shared/_azure_sign_in_links.html.erb +++ b/app/views/users/shared/_azure_sign_in_links.html.erb @@ -1,6 +1,6 @@ <% ApplicationSettings.instance.values['azure_ad_apps'].select { |v| v['enable_sign_in'] }.each do |config| %>
- <%= form_tag user_customazureactivedirectory_omniauth_authorize_path(provider: config['provider_name']), method: :post do %> + <%= form_tag user_customazureactivedirectory_omniauth_authorize_path(provider: config['provider_name']), method: :post, class: "azureAdForm" do %> <%= submit_tag config['sign_in_label'] || t('devise.sessions.new.azure_ad_submit'), class: 'btn btn-azure-ad' %> <% end %>
diff --git a/app/views/users/shared/_links.html.erb b/app/views/users/shared/_links.html.erb index a003f676d..934f50421 100644 --- a/app/views/users/shared/_links.html.erb +++ b/app/views/users/shared/_links.html.erb @@ -29,7 +29,7 @@ <%- if sso_enabled? && okta_configured? %>
- <%= form_tag user_okta_omniauth_authorize_path, method: :post do %> + <%= form_tag user_okta_omniauth_authorize_path, method: :post, id: 'oktaForm' do %> <%= submit_tag t('devise.okta.sign_in_label'), class: 'btn btn-okta' %> <% end %>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 7aa4f4c18..0f51a7ef9 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -98,6 +98,7 @@ Rails.application.config.assets.precompile += %w(label_templates/label_templates Rails.application.config.assets.precompile += %w(users/connected_devices.js) Rails.application.config.assets.precompile += %w(BrowserPrint-3.0.216.min.js) Rails.application.config.assets.precompile += %w(BrowserPrint-Zebra-1.0.216.min.js) +Rails.application.config.assets.precompile += %w(users/login_disclaimer.js) # Libraries needed for Handsontable formulas Rails.application.config.assets.precompile += %w(jquery.js)