bullet_train 1.20.0 → 1.21.1

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/account/two_factors_controller.rb +2 -0
  3. data/app/controllers/concerns/sessions/controller_base.rb +0 -4
  4. data/app/javascript/controllers/index.js +2 -0
  5. data/app/javascript/controllers/otp_response_controller.js +26 -0
  6. data/app/javascript/index.js +3 -1
  7. data/app/views/account/invitations/show.html.erb +3 -3
  8. data/app/views/account/memberships/_tombstones.html.erb +1 -1
  9. data/app/views/account/memberships/edit.html.erb +1 -1
  10. data/app/views/account/memberships/show.html.erb +4 -4
  11. data/app/views/account/onboarding/invitation_lists/new.html.erb +1 -1
  12. data/app/views/account/onboarding/user_details/edit.html.erb +1 -1
  13. data/app/views/account/onboarding/user_email/edit.html.erb +1 -1
  14. data/app/views/account/teams/_form.html.erb +1 -1
  15. data/app/views/account/teams/new.html.erb +2 -2
  16. data/app/views/account/two_factors/create.html.erb +1 -0
  17. data/app/views/account/two_factors/destroy.html.erb +1 -0
  18. data/app/views/account/two_factors/verify.html.erb +1 -0
  19. data/app/views/devise/registrations/_two_factor.html.erb +51 -49
  20. data/app/views/devise/registrations/edit.html.erb +1 -1
  21. data/app/views/devise/sessions/new.html.erb +2 -3
  22. data/app/views/devise/sessions/pre_otp.turbo_stream.erb +7 -0
  23. data/config/locales/en/users.en.yml +2 -0
  24. data/lib/bullet_train/version.rb +1 -1
  25. metadata +6 -6
  26. data/app/javascript/support/turn.js +0 -183
  27. data/app/views/account/two_factors/create.js.erb +0 -1
  28. data/app/views/account/two_factors/destroy.js.erb +0 -1
  29. data/app/views/account/two_factors/verify.js.erb +0 -1
  30. data/app/views/devise/sessions/pre_otp.js.erb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19a424300ea4463b1cd40cd375f81a9783a643a685f532ce54ef7ece2509850b
4
- data.tar.gz: cacee499473769cf2fb7ec70bbc5adf23b762d7b15bbdd2535bfb1c4dc01e9ec
3
+ metadata.gz: c1da30f86aa0ef66affbb136577d126f234f8eedbd3e58c7a8f73b517ceb063d
4
+ data.tar.gz: 2022e1d4979ad8d9a6bafeb8a2c68cd34682fbabf15cbde1ce3db64bac44cf08
5
5
  SHA512:
6
- metadata.gz: 6cc3b2cdecd60971309399675842e3c06266a2d4b6687bcdf88d93955cf776d1d8b78968a13240edf16a9ee34e6163baf843083701f6062eb16e25f758ad2a76
7
- data.tar.gz: '083b5681eda4de9d756d2c7ab81a51c5f684833bb641308dfe34bc051c853d9db70fde0fbbdab0da3d55a76625f4d7fba8503136aaf959b54027e8f90177c5fc'
6
+ metadata.gz: 49582c3f10e09877b70b3a357a5ad939c14ed0b533390b40163b173218e4a0323d4e2c86d6eaa4e02634617be6ae9c85b2947c560a671a23d106ad8aaab0022a
7
+ data.tar.gz: a09dd5dc0a2346c3c5fd402ecd3840233f7163694f1ad93e9b19a151e915418fdcfdb24283f48b8a7c9094ea41b7cc29b8358d4fe077286c45bace6f8603ddb2
@@ -1,6 +1,8 @@
1
1
  class Account::TwoFactorsController < Account::ApplicationController
2
2
  before_action :authenticate_user!
3
3
 
4
+ layout false
5
+
4
6
  def verify
5
7
  @user = current_user
6
8
 
@@ -40,9 +40,5 @@ module Sessions::ControllerBase
40
40
  if (@email = params["user"]["email"].downcase.strip.presence)
41
41
  @user = User.find_by(email: @email)
42
42
  end
43
-
44
- respond_to do |format|
45
- format.js
46
- end
47
43
  end
48
44
  end
@@ -9,6 +9,7 @@ import MobileMenuController from './mobile_menu_controller'
9
9
  import TextToggleController from './text_toggle_controller'
10
10
  import SelectAllController from './select_all_controller'
11
11
  import ConnectionWorkflowController from './connection_workflow_controller'
12
+ import OtpResponseController from './otp_response_controller'
12
13
 
13
14
  export const controllerDefinitions = [
14
15
  [BulkActionFormController, 'bulk_action_form_controller.js'],
@@ -20,6 +21,7 @@ export const controllerDefinitions = [
20
21
  [TextToggleController, 'text_toggle_controller.js'],
21
22
  [SelectAllController, 'select_all_controller.js'],
22
23
  [ConnectionWorkflowController, 'connection_workflow_controller.js'],
24
+ [OtpResponseController, 'otp_response_controller.js'],
23
25
  ].map(function(d) {
24
26
  const key = d[1]
25
27
  const controller = d[0]
@@ -0,0 +1,26 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="otp-response"
4
+ export default class extends Controller {
5
+ static values = {
6
+ otpRequired: Boolean,
7
+ };
8
+
9
+ connect() {
10
+ document.querySelector("#step-1").classList.add("hidden");
11
+ document.querySelector("#step-2").classList.remove("hidden");
12
+ if (this.otpRequiredValue) {
13
+ document.querySelector("#step-2-otp").classList.remove("hidden");
14
+ }
15
+ setTimeout(function() {
16
+ document.querySelector("#user_password").focus();
17
+ document.querySelector("#new_user").setAttribute('action', '/users/sign_in')
18
+ document.querySelector("#new_user").setAttribute('data-remote', 'false');
19
+
20
+ // TODO: Why do we need this? How is the button getting disabled?
21
+ // Does Turbo automatically disable submit buttons in a turbo form when it is submitted?
22
+ document.querySelector("#sign_in_submit").removeAttribute('disabled');
23
+ }, 1);
24
+ this.element.remove();
25
+ }
26
+ }
@@ -1,3 +1,5 @@
1
1
  export * from './controllers'
2
2
  import './electron'
3
- import './support/turn'
3
+
4
+ import Turn from '@domchristie/turn'
5
+ Turn.start();
@@ -13,17 +13,17 @@
13
13
 
14
14
  <div class="space-y-3 pb-1">
15
15
  <p><%= raw t('.accept_the_invitation', user_email: current_user.email) %></p>
16
- <%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), method: :post, class: 'button full' %>
16
+ <%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), data: { turbo_method: :post }, class: 'button full' %>
17
17
  </div>
18
18
 
19
19
  <%= render 'account/shared/decision_line' %>
20
20
 
21
21
  <div class="space-y-3">
22
22
  <p><%= t('.sign_out') %></p>
23
- <%= link_to t('.buttons.logout'), main_app.destroy_user_session_path, method: 'delete', class: 'button-alternative full' %>
23
+ <%= link_to t('.buttons.logout'), main_app.destroy_user_session_path, data: { turbo_method: 'delete' }, class: 'button-alternative full' %>
24
24
  </div>
25
25
  <% else %>
26
- <%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), method: :post, class: 'button full' %>
26
+ <%= link_to t('.buttons.join_team'), accept_account_invitation_path(@invitation.uuid), data: { turbo_method: :post }, class: 'button full' %>
27
27
  <% end %>
28
28
  </div>
29
29
  <% end %>
@@ -47,7 +47,7 @@
47
47
  <% end %>
48
48
  </td>
49
49
  <td class="text-right">
50
- <%= link_to t('.buttons.reinvite'), [:reinvite, :account, membership], class: 'button-secondary button-smaller', method: :post, data: {confirm: t('.buttons.confirmations.reinvite', membership_name: membership.name)} if can? :edit, membership %>
50
+ <%= link_to t('.buttons.reinvite'), [:reinvite, :account, membership], class: 'button-secondary button-smaller', data: { turbo_method: :post, turbo_confirm: t('.buttons.confirmations.reinvite', membership_name: membership.name)} if can? :edit, membership %>
51
51
  <%= link_to t('.buttons.show'), [:account, membership], class: 'button-secondary button-smaller' %>
52
52
  </td>
53
53
  </tr>
@@ -9,7 +9,7 @@
9
9
  <% if can? :destroy, @membership %>
10
10
  <%= render 'account/shared/box', divider: true do |box| %>
11
11
  <% box.t title: '.remove_header', description: '.remove_description' %>
12
- <% box.body.button_to t('.buttons.destroy'), [:account, @membership], method: :delete, data: { confirm: t('.buttons.confirmations.destroy') }, class: 'button' %>
12
+ <% box.body.button_to t('.buttons.destroy'), [:account, @membership], data: { turbo_method: :delete, turbo_confirm: t('.buttons.confirmations.destroy') }, class: 'button' %>
13
13
  <% end %>
14
14
  <% end %>
15
15
  <% end %>
@@ -34,19 +34,19 @@
34
34
 
35
35
  <% box.actions do %>
36
36
  <% if @membership.tombstone? %>
37
- <%= link_to t('.buttons.reinvite'), [:reinvite, :account, @membership], class: first_button_primary, method: :post, data: {confirm: t('.buttons.confirmations.reinvite', membership_name: @membership.name)} if can? :edit, @membership %>
37
+ <%= link_to t('.buttons.reinvite'), [:reinvite, :account, @membership], class: first_button_primary, data: {turbo_method: :post, turbo_confirm: t('.buttons.confirmations.reinvite', membership_name: @membership.name)} if can? :edit, @membership %>
38
38
  <% end %>
39
39
 
40
40
  <%= link_to t('.buttons.edit'), [:edit, :account, @membership], class: first_button_primary if can? :edit, @membership %>
41
41
 
42
42
  <% unless @membership.tombstone? %>
43
43
  <% if @membership.admin? %>
44
- <%= link_to t('.buttons.demote'), [:demote, :account, @membership], method: :post, data: { confirm: t('global.confirm_message') }, class: first_button_primary if can? :demote, @membership %>
44
+ <%= link_to t('.buttons.demote'), [:demote, :account, @membership], data: { turbo_method: :post, turbo_confirm: t('global.confirm_message') }, class: first_button_primary if can? :demote, @membership %>
45
45
  <% else %>
46
- <%= link_to t('.buttons.promote'), [:promote, :account, @membership], method: :post, data: { confirm: t('global.confirm_message') }, class: first_button_primary if can? :promote, @membership %>
46
+ <%= link_to t('.buttons.promote'), [:promote, :account, @membership], data: { turbo_method: :post, turbo_confirm: t('global.confirm_message') }, class: first_button_primary if can? :promote, @membership %>
47
47
  <% end %>
48
48
  <% if (can? :destroy, @membership) && (!@membership.platform_agent) %>
49
- <%= button_to t(".buttons.#{membership_destroy_locale_key(@membership)}"), [:account, @membership], method: :delete, data: { confirm: t(".buttons.confirmations.#{membership_destroy_locale_key(@membership)}", model_locales(@membership)) }, class: first_button_primary %>
49
+ <%= button_to t(".buttons.#{membership_destroy_locale_key(@membership)}"), [:account, @membership], method: :delete, data: { turbo_confirm: t(".buttons.confirmations.#{membership_destroy_locale_key(@membership)}", model_locales(@membership)) }, class: first_button_primary %>
50
50
  <% end %>
51
51
  <% end %>
52
52
 
@@ -22,7 +22,7 @@
22
22
  <% if other_teams.any? %>
23
23
  <%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
24
24
  <% else %>
25
- <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, method: 'delete' %>
25
+ <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, data: {turbo_method: 'delete'} %>
26
26
  <% end %>
27
27
  </div>
28
28
  <% end %>
@@ -39,7 +39,7 @@
39
39
  <% if other_teams.any? %>
40
40
  <%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
41
41
  <% else %>
42
- <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, method: 'delete' %>
42
+ <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path(@user, onboard_logout: true), class: first_button_primary, data: {turbo_method: 'delete'} %>
43
43
  <% end %>
44
44
  </div>
45
45
  <% end %>
@@ -24,7 +24,7 @@
24
24
  <% if current_user.teams.any? %>
25
25
  <%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
26
26
  <% else %>
27
- <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, method: 'delete' %>
27
+ <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, data:{turbo_method: 'delete'} %>
28
28
  <% end %>
29
29
  </div>
30
30
  <% end %>
@@ -18,7 +18,7 @@
18
18
  <div class="buttons">
19
19
  <%= form.submit (form.object.persisted? ? t('.buttons.update') : t('.buttons.create')), class: "button" %>
20
20
  <% if controller.action_name == "edit" %>
21
- <%= link_to t('account.teams.buttons.destroy'), [:account, team], method: :delete, data: { confirm: t('account.teams.buttons.confirmations.destroy') } %>
21
+ <%= link_to t('account.teams.buttons.destroy'), [:account, team], data: { turbo_method: :delete, turbo_confirm: t('account.teams.buttons.confirmations.destroy') } %>
22
22
  <% end %>
23
23
  <%= link_to t('global.buttons.cancel'), form.object.persisted? ? [:account, team] : [:account, :teams], class: "button-secondary" %>
24
24
  </div>
@@ -33,7 +33,7 @@ end
33
33
  <p><%= t('.log_out') %></p>
34
34
  </div>
35
35
 
36
- <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: 'button-alternative full', method: 'delete' %></p>
36
+ <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: 'button-alternative full', dat:{turbo_method: 'delete'} %></p>
37
37
 
38
38
  <%= render 'account/shared/decision_line' %>
39
39
 
@@ -70,7 +70,7 @@ end
70
70
  <% if current_user.teams.any? %>
71
71
  <%= link_to t('global.buttons.back'), main_app.account_teams_path, class: first_button_primary %>
72
72
  <% else %>
73
- <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, method: 'delete' %>
73
+ <%= link_to t('menus.main.labels.logout'), main_app.destroy_user_session_path, class: first_button_primary, data:{turbo_method: 'delete'} %>
74
74
  <% end %>
75
75
  </div>
76
76
  <% end %>
@@ -0,0 +1 @@
1
+ <%= render "devise/registrations/two_factor" %>
@@ -0,0 +1 @@
1
+ <%= render "devise/registrations/two_factor" %>
@@ -0,0 +1 @@
1
+ <%= render "devise/registrations/two_factor", locals: {verified: @verified} %>
@@ -1,62 +1,64 @@
1
- <%= render 'account/shared/box', divider: @backup_codes do |box| %>
2
- <% box.title t("users.edit.two_factor.header") %>
3
- <% box.description t("users.edit.two_factor.description_#{@user.otp_required_for_login? ? 'enabled' : 'disabled'}") %>
4
- <% if current_user.otp_secret %>
5
- <% if @backup_codes %>
6
- <% box.body do %>
7
- <%= render 'account/shared/alert' do %>
8
- <%= t('users.edit.two_factor.warning').html_safe %>
9
- <% end %>
1
+ <%= turbo_frame_tag "two-factor-frame" do %>
2
+ <%= render 'account/shared/box', divider: @backup_codes do |box| %>
3
+ <% box.title t("users.edit.two_factor.header") %>
4
+ <% box.description t("users.edit.two_factor.description_#{@user.otp_required_for_login? ? 'enabled' : 'disabled'}") %>
5
+ <% if current_user.otp_secret %>
6
+ <% if @backup_codes %>
7
+ <% box.body do %>
8
+ <%= render 'account/shared/alert' do %>
9
+ <%= t('users.edit.two_factor.warning').html_safe %>
10
+ <% end %>
10
11
 
11
- <p><%= t('users.edit.two_factor.instructions').html_safe %></p>
12
+ <p><%= t('users.edit.two_factor.instructions').html_safe %></p>
12
13
 
13
- <center class="py-4">
14
- <%= current_user.otp_qr_code.as_svg(
15
- offset: 0,
16
- color: '000',
17
- shape_rendering: 'crispEdges',
18
- module_size: 4,
19
- standalone: true
20
- ).html_safe %>
21
- </center>
14
+ <center class="py-4">
15
+ <%= current_user.otp_qr_code.as_svg(
16
+ offset: 0,
17
+ color: '000',
18
+ shape_rendering: 'crispEdges',
19
+ module_size: 4,
20
+ standalone: true
21
+ ).html_safe %>
22
+ </center>
22
23
 
23
- <p><%= t('users.edit.two_factor.recovery_codes').html_safe %></p>
24
+ <p><%= t('users.edit.two_factor.recovery_codes').html_safe %></p>
24
25
 
25
- <center>
26
- <% @backup_codes.each do |code| %>
27
- <p><code><%= code %></code></p>
28
- <% end %>
29
- </center>
26
+ <center>
27
+ <% @backup_codes.each do |code| %>
28
+ <p><code><%= code %></code></p>
29
+ <% end %>
30
+ </center>
30
31
 
31
- <%= form_for current_user, url: verify_account_two_factor_path, method: :post, remote:true, html: {class: 'form'} do |form| %>
32
- <div class="py-4">
33
- <%= render 'shared/fields/text_field', form: form, method: :otp_attempt %>
34
- </div>
35
- <%= form.submit t('users.edit.two_factor.buttons.verify'), class: 'button' %>
36
- <% end %>
32
+ <%= form_for current_user, url: verify_account_two_factor_path, method: :post, remote:true, html: {class: 'form'} do |form| %>
33
+ <div class="py-4">
34
+ <%= render 'shared/fields/text_field', form: form, method: :otp_attempt %>
35
+ </div>
36
+ <%= form.submit t('users.edit.two_factor.buttons.verify'), class: 'button' %>
37
+ <% end %>
38
+ <% end %>
37
39
  <% end %>
38
40
  <% end %>
39
- <% end %>
40
- <% box.actions do %>
41
- <div class="<%= 'hidden' if @backup_codes %> space-y">
42
- <% if local_assigns.has_key? :verified %>
43
- <% if verified %>
44
- <%= render 'account/shared/alert', color: 'blue' do %>
45
- <%= t('users.edit.two_factor.verification_success').html_safe %>
46
- <% end %>
47
- <% else %>
48
- <%= render 'account/shared/alert' do %>
49
- <%= t('users.edit.two_factor.verification_fail').html_safe %>
41
+ <% box.actions do %>
42
+ <div class="<%= 'hidden' if @backup_codes %> space-y">
43
+ <% if local_assigns.has_key? :verified %>
44
+ <% if verified %>
45
+ <%= render 'account/shared/alert', color: 'blue' do %>
46
+ <%= t('users.edit.two_factor.verification_success').html_safe %>
47
+ <% end %>
48
+ <% else %>
49
+ <%= render 'account/shared/alert' do %>
50
+ <%= t('users.edit.two_factor.verification_fail').html_safe %>
51
+ <% end %>
50
52
  <% end %>
51
53
  <% end %>
52
- <% end %>
53
54
 
54
- <% if current_user.otp_required_for_login? %>
55
- <%= link_to t('users.edit.two_factor.buttons.disable'), account_two_factor_path, method: :delete, remote: true, class: "button" %>
56
- <% else %>
57
- <%= link_to t('users.edit.two_factor.buttons.enable'), account_two_factor_path, method: :post, remote: true, class: "button" %>
58
- <% end %>
59
- </div>
55
+ <% if current_user.otp_required_for_login? %>
56
+ <%= link_to t('users.edit.two_factor.buttons.disable'), account_two_factor_path, data:{turbo_method: :delete, turbo_confirm: t('users.edit.two_factor.buttons.confirmations.disable')}, class: "button" %>
57
+ <% else %>
58
+ <%= link_to t('users.edit.two_factor.buttons.enable'), account_two_factor_path, data:{turbo_method: :post}, class: "button" %>
59
+ <% end %>
60
+ </div>
61
+ <% end %>
60
62
  <% end %>
61
63
  <% end %>
62
64
 
@@ -38,6 +38,6 @@
38
38
 
39
39
  <h3><%= t('devise.headers.cancel_account') %></h3>
40
40
 
41
- <p>Unhappy? <%= button_to t('devise.buttons.cancel_account'), registration_path(resource_name), data: { confirm: t('global.confirm_message') }, method: :delete %></p>
41
+ <p>Unhappy? <%= button_to t('devise.buttons.cancel_account'), registration_path(resource_name), data: { turbo_confirm: t('global.confirm_message') }, method: :delete %></p>
42
42
 
43
43
  <%= link_to t('global.buttons.back'), :back %>
@@ -2,8 +2,7 @@
2
2
  <% box.title t('devise.headers.sign_in') %>
3
3
  <% box.body do %>
4
4
  <% within_fields_namespace(:self) do %>
5
- <%# TODO: Turbo is set to `false` for now, but we may want to only bypass Turbo for JavaScript-based requests in the future. %>
6
- <%= form_for resource, as: resource_name, url: two_factor_authentication_enabled? ? users_pre_otp_path : session_path(resource_name), remote: two_factor_authentication_enabled?, html: {class: 'form'}, authenticity_token: true, data: {turbo: false} do |form| %>
5
+ <%= form_for resource, as: resource_name, url: two_factor_authentication_enabled? ? users_pre_otp_path : session_path(resource_name), html: {class: 'form'}, authenticity_token: true do |form| %>
7
6
  <% with_field_settings form: form do %>
8
7
  <%= render 'account/shared/notices', form: form %>
9
8
  <%= render 'account/shared/forms/errors', form: form %>
@@ -40,7 +39,7 @@
40
39
  </div>
41
40
  <% end %>
42
41
 
43
- <%= form.submit t('global.buttons.sign_in'), class: 'button full' %>
42
+ <%= form.submit t('global.buttons.sign_in'), class: 'button full', id: 'sign_in_submit' %>
44
43
  </div>
45
44
 
46
45
  <% if devise_mapping.rememberable? %>
@@ -0,0 +1,7 @@
1
+ <turbo-stream action="append" target="new_user">
2
+ <template>
3
+ <template
4
+ data-controller="otp-response"
5
+ data-otp-response-otp-required-value="<%= @user&.otp_required_for_login || false %>"></template>
6
+ </template>
7
+ </turbo-stream>
@@ -30,6 +30,8 @@ en:
30
30
  enable: Enable
31
31
  disable: Disable
32
32
  verify: Verify
33
+ confirmations:
34
+ disable: "Are you sure you want to disable 2FA?"
33
35
  buttons: *buttons
34
36
  notifications:
35
37
  updated: User was successfully updated.
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.20.0"
2
+ VERSION = "1.21.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
@@ -433,11 +433,11 @@ files:
433
433
  - app/javascript/controllers/form_controller.js
434
434
  - app/javascript/controllers/index.js
435
435
  - app/javascript/controllers/mobile_menu_controller.js
436
+ - app/javascript/controllers/otp_response_controller.js
436
437
  - app/javascript/controllers/select_all_controller.js
437
438
  - app/javascript/controllers/text_toggle_controller.js
438
439
  - app/javascript/electron/index.js
439
440
  - app/javascript/index.js
440
- - app/javascript/support/turn.js
441
441
  - app/mailers/concerns/mailers/base.rb
442
442
  - app/mailers/devise_mailer.rb
443
443
  - app/mailers/user_mailer.rb
@@ -497,9 +497,9 @@ files:
497
497
  - app/views/account/teams/edit.html.erb
498
498
  - app/views/account/teams/index.html.erb
499
499
  - app/views/account/teams/new.html.erb
500
- - app/views/account/two_factors/create.js.erb
501
- - app/views/account/two_factors/destroy.js.erb
502
- - app/views/account/two_factors/verify.js.erb
500
+ - app/views/account/two_factors/create.html.erb
501
+ - app/views/account/two_factors/destroy.html.erb
502
+ - app/views/account/two_factors/verify.html.erb
503
503
  - app/views/account/users/_breadcrumbs.html.erb
504
504
  - app/views/account/users/_fields.html.erb
505
505
  - app/views/account/users/_form.html.erb
@@ -519,7 +519,7 @@ files:
519
519
  - app/views/devise/registrations/edit.html.erb
520
520
  - app/views/devise/registrations/new.html.erb
521
521
  - app/views/devise/sessions/new.html.erb
522
- - app/views/devise/sessions/pre_otp.js.erb
522
+ - app/views/devise/sessions/pre_otp.turbo_stream.erb
523
523
  - app/views/devise/shared/_links.html.erb
524
524
  - app/views/devise/shared/_oauth.html.erb
525
525
  - app/views/devise/unlocks/new.html.erb
@@ -1,183 +0,0 @@
1
- // MIT License
2
- //
3
- // Copyright (c) 2021 Dom Christie
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in all
13
- // copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- // SOFTWARE.
22
-
23
- class Turn {
24
- constructor (action) {
25
- this.action = action
26
- this.beforeExitClasses = new Set()
27
- this.exitClasses = new Set()
28
- this.enterClasses = new Set()
29
- }
30
-
31
- exit () {
32
- this.animateOut = animationsEnd('[data-turn-exit]')
33
- this.addClasses('before-exit')
34
- requestAnimationFrame(() => {
35
- this.addClasses('exit')
36
- this.removeClasses('before-exit')
37
- })
38
- }
39
-
40
- async beforeEnter (event) {
41
- if (this.action === 'restore') return
42
-
43
- event.preventDefault()
44
-
45
- if (this.isPreview) {
46
- this.hasPreview = true
47
- await this.animateOut
48
- } else {
49
- await this.animateOut
50
- if (this.animateIn) await this.animateIn
51
- }
52
-
53
- event.detail.resume()
54
- }
55
-
56
- async enter () {
57
- this.removeClasses('exit')
58
-
59
- if (this.shouldAnimateEnter) {
60
- this.animateIn = animationsEnd('[data-turn-enter]')
61
- this.addClasses('enter')
62
- }
63
- }
64
-
65
- async complete () {
66
- await this.animateIn
67
- this.removeClasses('enter')
68
- }
69
-
70
- abort () {
71
- this.removeClasses('before-exit')
72
- this.removeClasses('exit')
73
- this.removeClasses('enter')
74
- }
75
-
76
- get shouldAnimateEnter () {
77
- if (this.action === 'restore') return false
78
- if (this.isPreview) return true
79
- if (this.hasPreview) return false
80
- return true
81
- }
82
-
83
- get isPreview () {
84
- return document.documentElement.hasAttribute('data-turbo-preview')
85
- }
86
-
87
- addClasses (type) {
88
- document.documentElement.classList.add(`turn-${type}`)
89
-
90
- Array.from(document.querySelectorAll(`[data-turn-${type}]`)).forEach((element) => {
91
- element.dataset[`turn${pascalCase(type)}`].split(/\s+/).forEach((klass) => {
92
- if (klass) {
93
- element.classList.add(klass)
94
- this[`${camelCase(type)}Classes`].add(klass)
95
- }
96
- })
97
- })
98
- }
99
-
100
- removeClasses (type) {
101
- document.documentElement.classList.remove(`turn-${type}`)
102
-
103
- Array.from(document.querySelectorAll(`[data-turn-${type}]`)).forEach((element) => {
104
- this[`${camelCase(type)}Classes`].forEach((klass) => element.classList.remove(klass))
105
- })
106
- }
107
- }
108
-
109
- Turn.start = function () {
110
- if (motionSafe()) {
111
- for (var event in this.eventListeners) {
112
- addEventListener(event, this.eventListeners[event])
113
- }
114
- }
115
- }
116
-
117
- Turn.stop = function () {
118
- for (var event in this.eventListeners) {
119
- removeEventListener(event, this.eventListeners[event])
120
- }
121
- delete this.currentTurn
122
- }
123
-
124
- Turn.eventListeners = {
125
- 'turbo:visit': function (event) {
126
- if (this.currentTurn) this.currentTurn.abort()
127
- this.currentTurn = new this(event.detail.action)
128
- this.currentTurn.exit()
129
- }.bind(Turn),
130
- 'turbo:before-render': function (event) {
131
- this.currentTurn.beforeEnter(event)
132
- }.bind(Turn),
133
- 'turbo:render': function () {
134
- this.currentTurn.enter()
135
- }.bind(Turn),
136
- 'turbo:load': function () {
137
- if (this.currentTurn) this.currentTurn.complete()
138
- }.bind(Turn),
139
- 'popstate': function () {
140
- if (this.currentTurn && this.currentTurn.action !== 'restore') {
141
- this.currentTurn.abort()
142
- }
143
- }.bind(Turn)
144
- }
145
-
146
- function prefersReducedMotion () {
147
- const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)')
148
- return !mediaQuery || mediaQuery.matches
149
- }
150
-
151
- function motionSafe () {
152
- return !prefersReducedMotion()
153
- }
154
-
155
- function animationsEnd (selector) {
156
- const elements = [...document.querySelectorAll(selector)]
157
-
158
- return Promise.all(elements.map((element) => {
159
- return new Promise((resolve) => {
160
- function listener () {
161
- element.removeEventListener('animationend', listener)
162
- resolve()
163
- }
164
- element.addEventListener('animationend', listener)
165
- })
166
- }))
167
- }
168
-
169
- function pascalCase (string) {
170
- return string.split(/[^\w]/).map(capitalize).join('')
171
- }
172
-
173
- function camelCase (string) {
174
- return string.split(/[^\w]/).map(
175
- (w, i) => i === 0 ? w.toLowerCase() : capitalize(w)
176
- ).join('')
177
- }
178
-
179
- function capitalize (string) {
180
- return string.replace(/^\w/, (c) => c.toUpperCase())
181
- }
182
-
183
- Turn.start()
@@ -1 +0,0 @@
1
- jQuery("#two-factor").html("<%= j render partial: "devise/registrations/two_factor"%>");
@@ -1 +0,0 @@
1
- jQuery("#two-factor").html("<%= j render partial: "devise/registrations/two_factor"%>");
@@ -1 +0,0 @@
1
- jQuery("#two-factor").html("<%= j render partial: "devise/registrations/two_factor", locals: {verified: @verified}%>");
@@ -1,12 +0,0 @@
1
- <% if @email %>
2
- document.querySelector("#step-1").classList.add("hidden");
3
- document.querySelector("#step-2").classList.remove("hidden");
4
- <% if @user&.otp_required_for_login %>
5
- document.querySelector("#step-2-otp").classList.remove("hidden");
6
- <% end %>
7
- setTimeout(function() {
8
- document.querySelector("#user_password").focus();
9
- document.querySelector("#new_user").setAttribute('action', '/users/sign_in')
10
- document.querySelector("#new_user").setAttribute('data-remote', 'false');
11
- }, 1);
12
- <% end %>