Merge pull request #5112 from aignatov-bio/ai-sci-7960-add-disclaimer-to-login-page

Add disclaimer modal [SCI-7960]
This commit is contained in:
aignatov-bio 2023-04-17 11:25:06 +02:00 committed by GitHub
commit 83790be734
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 2 deletions

View file

@ -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');
}());

View file

@ -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

View file

@ -0,0 +1,22 @@
<% if login_disclaimer %>
<div class="modal" id="loginDisclaimerModal" tabindex="-1" role="dialog" aria-labelledby="confirm-archive-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="confirm-archive-modal-label">
<%= login_disclaimer["title"] %>
</h4>
</div>
<div class="modal-body">
<%= login_disclaimer["body"] %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t("general.cancel") %></button>
<button type="button" class="btn btn-primary" data-action="submit"><%= login_disclaimer["action"] %></button>
</div>
</div>
</div>
</div>
<%= javascript_include_tag "users/login_disclaimer" %>
<% end %>

View file

@ -46,3 +46,5 @@
</div>
</div>
</div>
<%= render partial: 'login_disclaimer'%>

View file

@ -1,6 +1,6 @@
<% ApplicationSettings.instance.values['azure_ad_apps'].select { |v| v['enable_sign_in'] }.each do |config| %>
<div class="form-group">
<%= 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 %>
</div>

View file

@ -29,7 +29,7 @@
<%- if sso_enabled? && okta_configured? %>
<div class="okta-sign-in-actions">
<%= 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 %>
</div>

View file

@ -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)