mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Add UX
This commit is contained in:
parent
7d20bf6fea
commit
c592954400
5 changed files with 33 additions and 21 deletions
|
@ -102,10 +102,12 @@ class Users::SessionsController < Devise::SessionsController
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
generate_demo_project
|
generate_demo_project
|
||||||
flash[:notice] = t('devise.sessions.signed_in')
|
flash[:notice] = t('devise.sessions.signed_in')
|
||||||
else
|
|
||||||
flash.now[:alert] = t('Not correct recovery code')
|
|
||||||
end
|
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
|
else
|
||||||
|
flash[:alert] = t("devise.sessions.2fa_recovery.not_correct_code")
|
||||||
|
redirect_to new_user_session_path
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -676,7 +676,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
otp_recovery_codes.each do |recovery_code|
|
otp_recovery_codes.each do |recovery_code|
|
||||||
if Devise::Encryptor.compare(self.class, recovery_code, code)
|
if Devise::Encryptor.compare(self.class, recovery_code, code)
|
||||||
update(otp_recovery_codes: otp_recovery_codes.reject { |i| i == recovery_code })
|
update!(otp_recovery_codes: otp_recovery_codes.reject { |i| i == recovery_code })
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,16 +5,17 @@
|
||||||
<div class="center-block center-block-narrow">
|
<div class="center-block center-block-narrow">
|
||||||
<h1 class="log-in-title"><%= t "devise.sessions.2fa.title" %></h1>
|
<h1 class="log-in-title"><%= t "devise.sessions.2fa.title" %></h1>
|
||||||
<%= form_with url: users_authenticate_with_two_factor_url, local: true do %>
|
<%= form_with url: users_authenticate_with_two_factor_url, local: true do %>
|
||||||
<div class="input-group sci-input-container">
|
<p><%= t "devise.sessions.2fa.description" %></p>
|
||||||
|
<p class="input-group sci-input-container">
|
||||||
<%= label :otp, t("devise.sessions.2fa.field") %>
|
<%= label :otp, t("devise.sessions.2fa.field") %>
|
||||||
<%= text_field_tag(:otp, '', { class: "form-control sci-input-field", placeholder: t("devise.sessions.2fa.placeholder") })%>
|
<%= text_field_tag(:otp, '', { class: "form-control sci-input-field" })%>
|
||||||
</div>
|
</p>
|
||||||
|
|
||||||
<div class="actions" style="margin-top: 10px; margin-bottom: 10px;">
|
<p class="actions">
|
||||||
<%= button_tag t("devise.sessions.new.submit"), type: :submit, class: "btn btn-primary log-in-button" %>
|
<%= button_tag t("devise.sessions.2fa.enter"), type: :submit, class: "btn btn-primary" %>
|
||||||
</div>
|
</p>
|
||||||
|
|
||||||
<%= link_to 'I have a bypass code', users_two_factor_recovery_path %>
|
<%= link_to t("devise.sessions.2fa.bypass_code_link"), users_two_factor_recovery_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
<div class="sign-in-container">
|
<div class="sign-in-container">
|
||||||
<div class="sign-in-form-wrapper">
|
<div class="sign-in-form-wrapper">
|
||||||
<div class="center-block center-block-narrow">
|
<div class="center-block center-block-narrow">
|
||||||
<h1 class="log-in-title">2FA Bypass</h1>
|
<h1 class="log-in-title"><%= t "devise.sessions.2fa_recovery.title" %></h1>
|
||||||
<%= form_with url: users_authenticate_with_recovery_code_path, local: true do %>
|
<%= form_with url: users_authenticate_with_recovery_code_path, local: true do %>
|
||||||
<div class="input-group sci-input-container">
|
<p><%= t "devise.sessions.2fa_recovery.description" %></p>
|
||||||
<%= label :recovery_code, 'Bypass code' %>
|
<p class="input-group sci-input-container">
|
||||||
|
<%= label :recovery_code, t("devise.sessions.2fa_recovery.bypass_code") %>
|
||||||
<%= text_field_tag(:recovery_code, '', { class: "form-control sci-input-field" })%>
|
<%= text_field_tag(:recovery_code, '', { class: "form-control sci-input-field" })%>
|
||||||
</div>
|
</p>
|
||||||
|
|
||||||
<div class="actions" style="margin-top: 10px; margin-bottom: 10px;">
|
<div class="actions">
|
||||||
<%= button_tag 'Enter', type: :submit, class: "btn btn-primary" %>
|
<%= button_tag t("devise.sessions.2fa_recovery.enter"), type: :submit, class: "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,11 +34,19 @@ en:
|
||||||
remember_me: "Remember me"
|
remember_me: "Remember me"
|
||||||
submit: "Log in"
|
submit: "Log in"
|
||||||
2fa:
|
2fa:
|
||||||
title: "Two factor check"
|
title: "Two-factor authentication"
|
||||||
field: "One time password"
|
description: "Enter the one-time code found in your authenticator app to log in to SciNote."
|
||||||
placeholder: "Enter code"
|
field: "Authenticator code"
|
||||||
error_message: "One Time Password is not correct."
|
error_message: "One time code is not correct."
|
||||||
no_user_error: "Cannot find user!"
|
no_user_error: "Cannot find user!"
|
||||||
|
enter: "Enter"
|
||||||
|
bypass_code_link: "I have a bypass code"
|
||||||
|
2fa_recovery:
|
||||||
|
title: "2FA Bypass"
|
||||||
|
description: "Enter one of the bypass codes provided when you creted 2FA authentication. The code will no longer be valid after use."
|
||||||
|
bypass_code: "Bypass code"
|
||||||
|
enter: "Enter"
|
||||||
|
not_correct_code: "Not correct recovery code"
|
||||||
create:
|
create:
|
||||||
team_name: "%{user}'s projects"
|
team_name: "%{user}'s projects"
|
||||||
auth_token_create:
|
auth_token_create:
|
||||||
|
|
Loading…
Add table
Reference in a new issue