bullet_train 1.21.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e96df89a7d40b6e275f57575a3157fc6ee8bccfae6b9c2a14d0b872c894bf5e3
4
- data.tar.gz: f727d6df61d995e6e4d8b9e0a8f7143fd3881ab95b8baaa321f6e75ade40c9dd
3
+ metadata.gz: c1da30f86aa0ef66affbb136577d126f234f8eedbd3e58c7a8f73b517ceb063d
4
+ data.tar.gz: 2022e1d4979ad8d9a6bafeb8a2c68cd34682fbabf15cbde1ce3db64bac44cf08
5
5
  SHA512:
6
- metadata.gz: caf9f4bc490dae9ed4e1d05a6ea89d3e161c87862856229a13a87ec61c721480c6da32af4101143307bd748be22833a6956c8bac981210946feaf31eeb0937de
7
- data.tar.gz: 914984adb93662453c4d0fd6f1c2c58624f3fbc4bef6e2560a9451ba8f153fe28386877443fe838b5cf02bfdd8f4c8f9e971e8122ccde6e59db7efb55f8f9fb8
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
+ }
@@ -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, data:{turbo_method: :delete}, remote: true, class: "button" %>
56
- <% else %>
57
- <%= link_to t('users.edit.two_factor.buttons.enable'), account_two_factor_path, data:{turbo_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
 
@@ -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.21.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.21.0
4
+ version: 1.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
@@ -433,6 +433,7 @@ 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
@@ -496,9 +497,9 @@ files:
496
497
  - app/views/account/teams/edit.html.erb
497
498
  - app/views/account/teams/index.html.erb
498
499
  - app/views/account/teams/new.html.erb
499
- - app/views/account/two_factors/create.js.erb
500
- - app/views/account/two_factors/destroy.js.erb
501
- - 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
502
503
  - app/views/account/users/_breadcrumbs.html.erb
503
504
  - app/views/account/users/_fields.html.erb
504
505
  - app/views/account/users/_form.html.erb
@@ -518,7 +519,7 @@ files:
518
519
  - app/views/devise/registrations/edit.html.erb
519
520
  - app/views/devise/registrations/new.html.erb
520
521
  - app/views/devise/sessions/new.html.erb
521
- - app/views/devise/sessions/pre_otp.js.erb
522
+ - app/views/devise/sessions/pre_otp.turbo_stream.erb
522
523
  - app/views/devise/shared/_links.html.erb
523
524
  - app/views/devise/shared/_oauth.html.erb
524
525
  - app/views/devise/unlocks/new.html.erb
@@ -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 %>