rails_authentication 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +73 -7
- data/lib/generators/authentication/authentication_generator.rb +70 -8
- data/lib/generators/authentication/features/confirmable.rb +5 -5
- data/lib/generators/authentication/features/invitable.rb +5 -5
- data/lib/generators/authentication/features/lockable.rb +5 -5
- data/lib/generators/authentication/features/magic_link.rb +5 -5
- data/lib/generators/authentication/features/ott.rb +5 -5
- data/lib/generators/authentication/features/recoverable.rb +8 -6
- data/lib/generators/authentication/features/rememberable.rb +8 -3
- data/lib/generators/authentication/templates/app/controllers/concerns/authentication.rb.tt +61 -14
- data/lib/generators/authentication/templates/app/controllers/confirmations_controller.rb.tt +9 -5
- data/lib/generators/authentication/templates/app/controllers/invitations_controller.rb.tt +13 -4
- data/lib/generators/authentication/templates/app/controllers/magic_links_controller.rb.tt +9 -7
- data/lib/generators/authentication/templates/app/controllers/otts_controller.rb.tt +12 -9
- data/lib/generators/authentication/templates/app/controllers/passkey_sessions_controller.rb.tt +9 -7
- data/lib/generators/authentication/templates/app/controllers/passwords_controller.rb.tt +21 -8
- data/lib/generators/authentication/templates/app/controllers/registrations_controller.rb.tt +7 -5
- data/lib/generators/authentication/templates/app/controllers/sessions_controller.rb.tt +9 -7
- data/lib/generators/authentication/templates/app/controllers/unlocks_controller.rb.tt +7 -5
- data/lib/generators/authentication/templates/app/controllers/webauthn_credentials_controller.rb.tt +7 -3
- data/lib/generators/authentication/templates/app/mailers/confirmations_mailer.rb.tt +4 -2
- data/lib/generators/authentication/templates/app/mailers/invitations_mailer.rb.tt +3 -1
- data/lib/generators/authentication/templates/app/mailers/magic_links_mailer.rb.tt +3 -1
- data/lib/generators/authentication/templates/app/mailers/otts_mailer.rb.tt +3 -1
- data/lib/generators/authentication/templates/app/mailers/passwords_mailer.rb.tt +3 -1
- data/lib/generators/authentication/templates/app/mailers/unlocks_mailer.rb.tt +3 -1
- data/lib/generators/authentication/templates/app/models/concerns/confirmable_concern.rb.tt +7 -2
- data/lib/generators/authentication/templates/app/models/concerns/invitable_concern.rb.tt +12 -1
- data/lib/generators/authentication/templates/app/models/concerns/lockable_concern.rb.tt +8 -0
- data/lib/generators/authentication/templates/app/models/concerns/magic_link_concern.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/models/concerns/ott_concern.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/models/concerns/passkey_concern.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/models/concerns/recoverable_concern.rb.tt +8 -0
- data/lib/generators/authentication/templates/app/models/concerns/timeoutable_concern.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/models/concerns/trackable_concern.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/models/concerns/validatable_concern.rb.tt +5 -3
- data/lib/generators/authentication/templates/app/models/session.rb.tt +45 -0
- data/lib/generators/authentication/templates/app/models/user_auth.rb.tt +5 -3
- data/lib/generators/authentication/templates/app/models/webauthn_credential.rb.tt +2 -0
- data/lib/generators/authentication/templates/app/views/confirmations/new.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/confirmations_mailer/confirmation_instructions.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/confirmations_mailer/confirmation_instructions.text.erb.tt +2 -2
- data/lib/generators/authentication/templates/app/views/invitations/edit.html.erb.tt +4 -4
- data/lib/generators/authentication/templates/app/views/invitations/new.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/invitations_mailer/invitation_instructions.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/invitations_mailer/invitation_instructions.text.erb.tt +2 -2
- data/lib/generators/authentication/templates/app/views/magic_links/new.html.erb.tt +4 -4
- data/lib/generators/authentication/templates/app/views/magic_links_mailer/magic_link.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/magic_links_mailer/magic_link.text.erb.tt +2 -3
- data/lib/generators/authentication/templates/app/views/otts/edit.html.erb.tt +7 -7
- data/lib/generators/authentication/templates/app/views/otts_mailer/ott.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/otts_mailer/ott.text.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/passwords/edit.html.erb.tt +9 -0
- data/lib/generators/authentication/templates/app/views/passwords/new.html.erb.tt +8 -0
- data/lib/generators/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt +2 -2
- data/lib/generators/authentication/templates/app/views/registrations/edit.html.erb.tt +6 -6
- data/lib/generators/authentication/templates/app/views/registrations/new.html.erb.tt +6 -6
- data/lib/generators/authentication/templates/app/views/sessions/new.html.erb.tt +20 -16
- data/lib/generators/authentication/templates/app/views/unlocks/new.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/unlocks_mailer/unlock_instructions.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/unlocks_mailer/unlock_instructions.text.erb.tt +3 -3
- data/lib/generators/authentication/templates/app/views/webauthn_credentials/index.html.erb.tt +5 -5
- data/lib/generators/authentication/templates/app/views/webauthn_credentials/new.html.erb.tt +12 -6
- data/lib/generators/authentication/templates/config/initializers/webauthn.rb.tt +2 -0
- data/lib/generators/authentication/templates/config/locales/authentication.en.yml.tt +421 -0
- data/lib/generators/authentication/templates/db/migrate/add_rememberable_to_sessions.rb.tt +5 -0
- data/lib/generators/authentication/templates/db/migrate/remove_remember_created_at_from_users.rb.tt +11 -0
- data/lib/rails_authentication/version.rb +1 -1
- metadata +8 -3
- data/lib/generators/authentication/templates/app/models/concerns/rememberable_concern.rb.tt +0 -15
- data/lib/generators/authentication/templates/db/migrate/add_rememberable_to_users.rb.tt +0 -5
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class UserAuth < ApplicationRecord
|
|
2
4
|
# user is optional so failed attempts against unknown email addresses still get recorded
|
|
3
5
|
belongs_to :user, optional: true
|
|
@@ -8,9 +10,9 @@ class UserAuth < ApplicationRecord
|
|
|
8
10
|
def self.record(user, request, success:, failure_reason: nil)
|
|
9
11
|
create!(
|
|
10
12
|
user: user,
|
|
11
|
-
ip: request
|
|
12
|
-
user_agent: request
|
|
13
|
-
referrer: request
|
|
13
|
+
ip: request&.remote_ip || "",
|
|
14
|
+
user_agent: request&.user_agent || "",
|
|
15
|
+
referrer: request&.referer || "",
|
|
14
16
|
success: success,
|
|
15
17
|
failure_reason: failure_reason
|
|
16
18
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
|
|
5
5
|
<%%= form_with url: confirmations_path do |form| %>
|
|
6
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
7
|
-
<%%= form.submit
|
|
6
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
7
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
8
8
|
<%% end %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
3
|
-
<%%= link_to
|
|
2
|
+
<%%= t('.confirm_on') %>
|
|
3
|
+
<%%= link_to t('.confirmation_page'), confirmation_url(@user.confirmation_token) %>.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, ConfirmableConcern::CONFIRMATION_TOKEN_EXPIRES_IN)) %>
|
|
6
6
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
<%%= t('.confirm_on') %>
|
|
2
2
|
<%%= confirmation_url(@user.confirmation_token) %>
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, ConfirmableConcern::CONFIRMATION_TOKEN_EXPIRES_IN)) %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
|
|
5
5
|
<%%= form_with url: invitation_path(params[:token]), method: :patch do |form| %>
|
|
6
|
-
<%%= form.password_field :password, required: true, autofocus: true, autocomplete: "new-password", placeholder:
|
|
7
|
-
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder:
|
|
8
|
-
<%%= form.submit
|
|
6
|
+
<%%= form.password_field :password, required: true, autofocus: true, autocomplete: "new-password", placeholder: t('.form.input.password.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
7
|
+
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: t('.form.input.password_confirmation.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
8
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
9
9
|
<%% end %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
|
5
5
|
|
|
6
6
|
<%%= form_with url: invitations_path do |form| %>
|
|
7
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, placeholder:
|
|
8
|
-
<%%= form.submit
|
|
7
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, placeholder: t('.form.input.email.placeholder') %><br>
|
|
8
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
9
9
|
<%% end %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
3
|
-
<%%= link_to
|
|
2
|
+
<%%= t('.activate_on') %>
|
|
3
|
+
<%%= link_to t('.invitation_page'), edit_invitation_url(@user.invitation_token) %>.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, InvitableConcern::INVITATION_TOKEN_EXPIRES_IN)) %>
|
|
6
6
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
<%%= t('.activate_on') %>
|
|
2
2
|
<%%= edit_invitation_url(@user.invitation_token) %>
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, InvitableConcern::INVITATION_TOKEN_EXPIRES_IN)) %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
|
5
5
|
|
|
6
6
|
<%%= form_with url: magic_links_path do |form| %>
|
|
7
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
8
|
-
<%%= form.submit
|
|
7
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
8
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
9
9
|
<%% end %>
|
|
10
10
|
<br>
|
|
11
11
|
|
|
12
|
-
<%%= link_to
|
|
12
|
+
<%%= link_to t('.links.session'), new_session_path %>
|
data/lib/generators/authentication/templates/app/views/magic_links_mailer/magic_link.html.erb.tt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
3
|
-
<%%= link_to
|
|
2
|
+
<%%= t('.sign_in_on') %>
|
|
3
|
+
<%%= link_to t('.magic_link_page'), magic_link_url(@user.magic_link_token) %>.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, MagicLinkConcern::MAGIC_LINK_EXPIRES_IN)) %>
|
|
6
6
|
</p>
|
data/lib/generators/authentication/templates/app/views/magic_links_mailer/magic_link.text.erb.tt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<%%= t('.sign_in_on') %>
|
|
3
2
|
<%%= magic_link_url(@user.magic_link_token) %>
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, MagicLinkConcern::MAGIC_LINK_EXPIRES_IN)) %>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
|
5
5
|
|
|
6
6
|
<p>
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
<%%= t('.emailed_code_to', digit_count: OttConcern::OTT_CODE_LENGTH, email: session[:ott_email_address]) %>
|
|
8
|
+
<%%= t('.expires_in', expires_in: distance_of_time_in_words(0, OttConcern::OTT_EXPIRES_IN)) %>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<%%= form_with url: ott_path, method: :patch do |form| %>
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
<%% OttConcern::OTT_CODE_LENGTH.times do |i| %>
|
|
15
15
|
<input type="text" inputmode="numeric" pattern="[0-9]*" maxlength="<%%= OttConcern::OTT_CODE_LENGTH %>" required
|
|
16
16
|
autocomplete="<%%= i.zero? ? "one-time-code" : "off" %>"
|
|
17
|
-
aria-label="
|
|
17
|
+
aria-label="<%%= t('.form.input.digit.aria', digit: i + 1) %>" <%%= "autofocus" if i.zero? %>
|
|
18
18
|
style="width:2em;text-align:center;font-size:1.5em">
|
|
19
19
|
<%% end %>
|
|
20
20
|
</div>
|
|
21
21
|
<br>
|
|
22
22
|
<% if rememberable? -%>
|
|
23
|
-
<%%= form.check_box :remember_me %> <%%= form.label :remember_me,
|
|
23
|
+
<%%= form.check_box :remember_me %> <%%= form.label :remember_me, t('.form.input.remember.label') %><br>
|
|
24
24
|
<% end -%>
|
|
25
|
-
<%%= form.submit
|
|
25
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
26
26
|
<%% end %>
|
|
27
27
|
<br>
|
|
28
28
|
|
|
29
|
-
<%%= button_to
|
|
29
|
+
<%%= button_to t('.buttons.resend'), ott_path, method: :post %>
|
|
30
30
|
|
|
31
31
|
<script>
|
|
32
32
|
(function() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><%%= t('.sign_in_code') %></p>
|
|
2
2
|
|
|
3
3
|
<p><strong><%%= @user.ott_code %></strong></p>
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, OttConcern::OTT_EXPIRES_IN)) %>
|
|
7
|
+
<%%= t('.ignore') %>
|
|
8
8
|
</p>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<%%= t('.sign_in_code') %>
|
|
2
2
|
|
|
3
3
|
<%%= @user.ott_code %>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, OttConcern::OTT_EXPIRES_IN)) %>
|
|
6
|
+
<%%= t('.ignore') %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
|
+
|
|
3
|
+
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
|
+
|
|
5
|
+
<%%= form_with url: password_path(params[:token]), method: :put do |form| %>
|
|
6
|
+
<%%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: t('.form.input.password.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
7
|
+
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: t('.form.input.password_confirmation.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
8
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
9
|
+
<%% end %>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
|
+
|
|
3
|
+
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
|
+
|
|
5
|
+
<%%= form_with url: passwords_path do |form| %>
|
|
6
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
7
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
8
|
+
<%% end %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
3
|
-
<%%= link_to
|
|
2
|
+
<%%= t('.reset_on') %>
|
|
3
|
+
<%%= link_to t('.reset_page'), edit_password_url(@user.reset_password_token) %>.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, RecoverableConcern::RESET_PASSWORD_TOKEN_EXPIRES_IN)) %>
|
|
6
6
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
<%%= t('.reset_on') %>
|
|
2
2
|
<%%= edit_password_url(@user.reset_password_token) %>
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
<%%= t('.expire_in', ttl: distance_of_time_in_words(0, RecoverableConcern::RESET_PASSWORD_TOKEN_EXPIRES_IN)) %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
<%%= form_with url: registration_path, method: :patch do |form| %>
|
|
15
15
|
<%%= form.email_field :email_address, required: true, autocomplete: "username", value: @user.email_address %><br>
|
|
16
|
-
<%%= form.password_field :password, autocomplete: "new-password", placeholder:
|
|
17
|
-
<%%= form.password_field :password_confirmation, autocomplete: "new-password", placeholder:
|
|
18
|
-
<%%= form.submit
|
|
16
|
+
<%%= form.password_field :password, autocomplete: "new-password", placeholder: t('.form.input.password.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
17
|
+
<%%= form.password_field :password_confirmation, autocomplete: "new-password", placeholder: t('.form.input.password_confirmation.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
18
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
19
19
|
<%% end %>
|
|
20
20
|
<br>
|
|
21
21
|
|
|
22
22
|
<% if passkey? -%>
|
|
23
|
-
<%%= link_to
|
|
23
|
+
<%%= link_to t('.links.passkeys'), webauthn_credentials_path %>
|
|
24
24
|
<br><br>
|
|
25
25
|
<% end -%>
|
|
26
|
-
<%%= button_to
|
|
26
|
+
<%%= button_to t('.links.delete'), registration_path, method: :delete, data: { turbo_confirm: t('.confirmation.delete') } %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
<%% end %>
|
|
12
12
|
|
|
13
13
|
<%%= form_with url: registration_path do |form| %>
|
|
14
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
15
|
-
<%%= form.password_field :password, required: true, autocomplete: "new-password", placeholder:
|
|
16
|
-
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder:
|
|
17
|
-
<%%= form.submit
|
|
14
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.form.input.email.placeholder'), value: @user.email_address %><br>
|
|
15
|
+
<%%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: t('.form.input.password.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
16
|
+
<%%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: t('.form.input.password_confirmation.placeholder'), maxlength: <%= password_maxlength %> %><br>
|
|
17
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
18
18
|
<%% end %>
|
|
19
19
|
<br>
|
|
20
20
|
|
|
21
|
-
<%%= link_to
|
|
21
|
+
<%%= link_to t('.links.sign_in'), new_session_path %>
|
|
@@ -4,34 +4,34 @@
|
|
|
4
4
|
<% if ott? -%>
|
|
5
5
|
<%% if params[:with_password].blank? %>
|
|
6
6
|
<%%= form_with url: ott_path do |form| %>
|
|
7
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
8
|
-
<%%= form.submit
|
|
7
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.ott.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
8
|
+
<%%= form.submit t('.ott.form.button.submit') %>
|
|
9
9
|
<%% end %>
|
|
10
10
|
<br>
|
|
11
11
|
|
|
12
|
-
<br><%%= link_to
|
|
12
|
+
<br><%%= link_to t('.links.session'), new_session_path(with_password: 1) %>
|
|
13
13
|
<%% else %>
|
|
14
14
|
<% end -%>
|
|
15
15
|
<%%= form_with url: session_path do |form| %>
|
|
16
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
17
|
-
<%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder:
|
|
16
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.session.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
17
|
+
<%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: t('.session.form.input.password.placeholder'), maxlength: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED %><br>
|
|
18
18
|
<% if rememberable? -%>
|
|
19
|
-
<%%= form.check_box :remember_me %> <%%= form.label :remember_me,
|
|
19
|
+
<%%= form.check_box :remember_me %> <%%= form.label :remember_me, t('.session.form.input.remember.label') %><br>
|
|
20
20
|
<% end -%>
|
|
21
|
-
<%%= form.submit
|
|
21
|
+
<%%= form.submit t('.session.form.button.submit') %>
|
|
22
22
|
<%% end %>
|
|
23
23
|
<br>
|
|
24
24
|
<% if ott? -%>
|
|
25
25
|
|
|
26
|
-
<br><%%= link_to
|
|
26
|
+
<br><%%= link_to t('.links.ott'), new_session_path %>
|
|
27
27
|
<%% end %>
|
|
28
28
|
<% end -%>
|
|
29
29
|
|
|
30
30
|
<% if magic_link? -%>
|
|
31
|
-
<br><%%= link_to
|
|
31
|
+
<br><%%= link_to t('.links.magic_link'), new_magic_link_path %>
|
|
32
32
|
<% end -%>
|
|
33
33
|
<% if passkey? -%>
|
|
34
|
-
<br><%%= button_tag
|
|
34
|
+
<br><%%= button_tag t('.links.passkey'), type: "button", id: "passkey-sign-in-button" %>
|
|
35
35
|
<%%= tag.span "", id: "passkey-sign-in-error", style: "color:red" %>
|
|
36
36
|
|
|
37
37
|
<%%= javascript_tag do %>
|
|
@@ -62,7 +62,11 @@
|
|
|
62
62
|
try {
|
|
63
63
|
credential = await navigator.credentials.get({ publicKey: options });
|
|
64
64
|
} catch (error) {
|
|
65
|
-
|
|
65
|
+
// The browser's own message is technical, so show a translated one and log the original.
|
|
66
|
+
console.error(error);
|
|
67
|
+
document.getElementById("passkey-sign-in-error").textContent = error.name === "NotAllowedError"
|
|
68
|
+
? "<%%= j t('.error.cancelled') %>"
|
|
69
|
+
: "<%%= j t('.error.passkey') %>";
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -89,19 +93,19 @@
|
|
|
89
93
|
if (response.ok) {
|
|
90
94
|
window.location.href = result.redirect_to;
|
|
91
95
|
} else {
|
|
92
|
-
document.getElementById("passkey-sign-in-error").textContent = result.error || "
|
|
96
|
+
document.getElementById("passkey-sign-in-error").textContent = result.error || "<%%= j t('.error.passkey') %>";
|
|
93
97
|
}
|
|
94
98
|
});
|
|
95
99
|
})();
|
|
96
100
|
<%% end %>
|
|
97
101
|
<% end -%>
|
|
98
|
-
<br><%%= link_to
|
|
102
|
+
<br><%%= link_to t('.links.forgot_password'), new_password_path %>
|
|
99
103
|
<% if registerable? -%>
|
|
100
|
-
<br><%%= link_to
|
|
104
|
+
<br><%%= link_to t('.links.sign_up'), new_registration_path %>
|
|
101
105
|
<% end -%>
|
|
102
106
|
<% if confirmable? -%>
|
|
103
|
-
<br><%%= link_to
|
|
107
|
+
<br><%%= link_to t('.links.resend_confirmation'), new_confirmation_path %>
|
|
104
108
|
<% end -%>
|
|
105
109
|
<% if lockable? -%>
|
|
106
|
-
<br><%%= link_to
|
|
110
|
+
<br><%%= link_to t('.links.resend_unlock'), new_unlock_path %>
|
|
107
111
|
<% end -%>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
|
|
5
5
|
<%%= form_with url: unlocks_path do |form| %>
|
|
6
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder:
|
|
7
|
-
<%%= form.submit
|
|
6
|
+
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: t('.form.input.email.placeholder'), value: params[:email_address] %><br>
|
|
7
|
+
<%%= form.submit t('.form.button.submit') %>
|
|
8
8
|
<%% end %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
2
|
+
<%%= t('.attempts') %>
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
<%%= t('.unlock_on') %> <%%= link_to t('.unlock_page'), unlock_url(@user.unlock_token) %>,
|
|
5
|
+
<%%= t('.or_wait', ttl: distance_of_time_in_words(0, LockableConcern::UNLOCK_IN)) %>
|
|
6
6
|
</p>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<%%= t('.attempts') %>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<%%= t('.unlock_on') %>
|
|
4
4
|
<%%= unlock_url(@user.unlock_token) %>
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
<%%= t('.or_wait', ttl: distance_of_time_in_words(0, LockableConcern::UNLOCK_IN)) %>
|
data/lib/generators/authentication/templates/app/views/webauthn_credentials/index.html.erb.tt
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
|
5
5
|
|
|
6
6
|
<%% if @webauthn_credentials.empty? %>
|
|
7
|
-
<p
|
|
7
|
+
<p><%%= t('.none') %></p>
|
|
8
8
|
<%% else %>
|
|
9
9
|
<ul>
|
|
10
10
|
<%% @webauthn_credentials.each do |credential| %>
|
|
11
11
|
<li>
|
|
12
|
-
<%%= credential.nickname
|
|
13
|
-
<%%= button_to
|
|
12
|
+
<%%= t('.account_added', nickname: credential.nickname, date_added: credential.created_at.to_date) %>
|
|
13
|
+
<%%= button_to t('.buttons.remove'), webauthn_credential_path(credential), method: :delete, data: { turbo_confirm: t('.confirmations.remove') } %>
|
|
14
14
|
</li>
|
|
15
15
|
<%% end %>
|
|
16
16
|
</ul>
|
|
17
17
|
<%% end %>
|
|
18
18
|
|
|
19
|
-
<br><%%= link_to
|
|
19
|
+
<br><%%= link_to t('.links.add'), new_webauthn_credential_path %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1><%%= t('.heading') %></h1>
|
|
2
2
|
|
|
3
3
|
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
|
4
4
|
<%%= tag.span "", id: "passkey-error", style: "color:red" %>
|
|
5
5
|
|
|
6
|
-
<%%= label_tag :passkey_nickname,
|
|
7
|
-
<%%= text_field_tag :passkey_nickname, nil, placeholder:
|
|
6
|
+
<%%= label_tag :passkey_nickname, t('.form.input.nickname.label') %>
|
|
7
|
+
<%%= text_field_tag :passkey_nickname, nil, placeholder: t('.form.input.nickname.placeholder') %><br><br>
|
|
8
8
|
|
|
9
|
-
<%%= button_tag
|
|
9
|
+
<%%= button_tag t('.form.button.submit'), type: "button", id: "create-passkey-button" %>
|
|
10
10
|
|
|
11
11
|
<%%= javascript_tag do %>
|
|
12
12
|
(function () {
|
|
@@ -38,7 +38,13 @@
|
|
|
38
38
|
try {
|
|
39
39
|
credential = await navigator.credentials.create({ publicKey: options });
|
|
40
40
|
} catch (error) {
|
|
41
|
-
|
|
41
|
+
// The browser's own message is technical, so show a translated one and log the original.
|
|
42
|
+
console.error(error);
|
|
43
|
+
const messages = {
|
|
44
|
+
InvalidStateError: "<%%= j t('.error.already_registered') %>",
|
|
45
|
+
NotAllowedError: "<%%= j t('.error.cancelled') %>"
|
|
46
|
+
};
|
|
47
|
+
document.getElementById("passkey-error").textContent = messages[error.name] || "<%%= j t('.error.save') %>";
|
|
42
48
|
return;
|
|
43
49
|
}
|
|
44
50
|
|
|
@@ -64,7 +70,7 @@
|
|
|
64
70
|
if (response.ok) {
|
|
65
71
|
window.location.href = result.redirect_to;
|
|
66
72
|
} else {
|
|
67
|
-
document.getElementById("passkey-error").textContent = result.error || "
|
|
73
|
+
document.getElementById("passkey-error").textContent = result.error || "<%%= j t('.error.save') %>";
|
|
68
74
|
}
|
|
69
75
|
});
|
|
70
76
|
})();
|