quo_vadis 1.4.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +11 -7
  3. data/CHANGELOG.md +22 -0
  4. data/Gemfile +11 -1
  5. data/LICENSE.txt +21 -0
  6. data/README.md +453 -127
  7. data/Rakefile +15 -9
  8. data/app/controllers/quo_vadis/confirmations_controller.rb +102 -0
  9. data/app/controllers/quo_vadis/logs_controller.rb +20 -0
  10. data/app/controllers/quo_vadis/password_resets_controller.rb +65 -0
  11. data/app/controllers/quo_vadis/passwords_controller.rb +26 -0
  12. data/app/controllers/quo_vadis/recovery_codes_controller.rb +54 -0
  13. data/app/controllers/quo_vadis/sessions_controller.rb +50 -132
  14. data/app/controllers/quo_vadis/totps_controller.rb +72 -0
  15. data/app/controllers/quo_vadis/twofas_controller.rb +26 -0
  16. data/app/mailers/quo_vadis/mailer.rb +73 -0
  17. data/app/models/quo_vadis/account.rb +59 -0
  18. data/app/models/quo_vadis/account_confirmation_token.rb +17 -0
  19. data/app/models/quo_vadis/log.rb +57 -0
  20. data/app/models/quo_vadis/password.rb +52 -0
  21. data/app/models/quo_vadis/password_reset_token.rb +17 -0
  22. data/app/models/quo_vadis/recovery_code.rb +26 -0
  23. data/app/models/quo_vadis/session.rb +55 -0
  24. data/app/models/quo_vadis/token.rb +42 -0
  25. data/app/models/quo_vadis/totp.rb +56 -0
  26. data/bin/console +15 -0
  27. data/bin/rails +21 -0
  28. data/bin/setup +8 -0
  29. data/config/locales/quo_vadis.en.yml +50 -23
  30. data/config/routes.rb +46 -12
  31. data/db/migrate/202102150904_setup.rb +48 -0
  32. data/lib/generators/quo_vadis/install_generator.rb +4 -23
  33. data/lib/quo_vadis.rb +103 -97
  34. data/lib/quo_vadis/controller.rb +228 -0
  35. data/lib/quo_vadis/crypt.rb +43 -0
  36. data/lib/quo_vadis/current_request_details.rb +11 -0
  37. data/lib/quo_vadis/defaults.rb +18 -0
  38. data/lib/quo_vadis/encrypted_type.rb +17 -0
  39. data/lib/quo_vadis/engine.rb +9 -11
  40. data/lib/quo_vadis/hmacable.rb +26 -0
  41. data/lib/quo_vadis/ip_masking.rb +31 -0
  42. data/lib/quo_vadis/model.rb +86 -0
  43. data/lib/quo_vadis/version.rb +3 -1
  44. data/quo_vadis.gemspec +20 -25
  45. data/test/dummy/README.markdown +1 -0
  46. data/test/dummy/Rakefile +2 -6
  47. data/test/dummy/app/controllers/application_controller.rb +0 -1
  48. data/test/dummy/app/controllers/articles_controller.rb +8 -11
  49. data/test/dummy/app/controllers/sign_ups_controller.rb +42 -0
  50. data/test/dummy/app/controllers/users_controller.rb +13 -5
  51. data/test/dummy/app/models/application_record.rb +3 -0
  52. data/test/dummy/app/models/article.rb +2 -1
  53. data/test/dummy/app/models/person.rb +5 -2
  54. data/test/dummy/app/models/user.rb +4 -1
  55. data/test/dummy/app/views/articles/also_secret.html.erb +1 -0
  56. data/test/dummy/app/views/articles/index.html.erb +1 -1
  57. data/test/dummy/app/views/articles/secret.html.erb +1 -0
  58. data/test/dummy/app/views/articles/very_secret.html.erb +2 -0
  59. data/test/dummy/app/views/layouts/application.html.erb +41 -25
  60. data/test/dummy/app/views/quo_vadis/confirmations/edit.html.erb +10 -0
  61. data/test/dummy/app/views/quo_vadis/confirmations/edit_email.html.erb +14 -0
  62. data/test/dummy/app/views/quo_vadis/confirmations/index.html.erb +14 -0
  63. data/test/dummy/app/views/quo_vadis/confirmations/new.html.erb +16 -0
  64. data/test/dummy/app/views/quo_vadis/logs/index.html.erb +28 -0
  65. data/test/dummy/app/views/quo_vadis/mailer/account_confirmation.text.erb +4 -0
  66. data/test/dummy/app/views/quo_vadis/mailer/email_change_notification.text.erb +8 -0
  67. data/test/dummy/app/views/quo_vadis/mailer/identifier_change_notification.text.erb +8 -0
  68. data/test/dummy/app/views/quo_vadis/mailer/password_change_notification.text.erb +8 -0
  69. data/test/dummy/app/views/quo_vadis/mailer/password_reset_notification.text.erb +8 -0
  70. data/test/dummy/app/views/quo_vadis/mailer/recovery_codes_generation_notification.text.erb +8 -0
  71. data/test/dummy/app/views/quo_vadis/mailer/reset_password.text.erb +4 -0
  72. data/test/dummy/app/views/quo_vadis/mailer/totp_reuse_notification.text.erb +6 -0
  73. data/test/dummy/app/views/quo_vadis/mailer/totp_setup_notification.text.erb +8 -0
  74. data/test/dummy/app/views/quo_vadis/mailer/twofa_deactivated_notification.text.erb +8 -0
  75. data/test/dummy/app/views/quo_vadis/password_resets/edit.html.erb +25 -0
  76. data/test/dummy/app/views/quo_vadis/password_resets/index.html.erb +5 -0
  77. data/test/dummy/app/views/quo_vadis/password_resets/new.html.erb +12 -0
  78. data/test/dummy/app/views/quo_vadis/passwords/edit.html.erb +30 -0
  79. data/test/dummy/app/views/quo_vadis/recovery_codes/challenge.html.erb +11 -0
  80. data/test/dummy/app/views/quo_vadis/recovery_codes/index.html.erb +25 -0
  81. data/test/dummy/app/views/quo_vadis/sessions/index.html.erb +26 -0
  82. data/test/dummy/app/views/quo_vadis/sessions/new.html.erb +24 -0
  83. data/test/dummy/app/views/quo_vadis/totps/challenge.html.erb +11 -0
  84. data/test/dummy/app/views/quo_vadis/totps/new.html.erb +17 -0
  85. data/test/dummy/app/views/quo_vadis/twofas/show.html.erb +20 -0
  86. data/test/dummy/app/views/sign_ups/new.html.erb +37 -0
  87. data/test/dummy/app/views/sign_ups/show.html.erb +5 -0
  88. data/test/dummy/app/views/users/new.html.erb +32 -9
  89. data/test/dummy/config.ru +6 -3
  90. data/test/dummy/config/application.rb +18 -9
  91. data/test/dummy/config/boot.rb +3 -9
  92. data/test/dummy/config/database.yml +2 -14
  93. data/test/dummy/config/environment.rb +2 -3
  94. data/test/dummy/config/initializers/quo_vadis.rb +5 -75
  95. data/test/dummy/config/routes.rb +11 -3
  96. data/test/dummy/db/migrate/202102121932_create_users.rb +10 -0
  97. data/test/dummy/db/migrate/202102121935_create_people.rb +10 -0
  98. data/test/dummy/db/schema.rb +80 -21
  99. data/test/fixtures/quo_vadis/mailer/account_confirmation.text +4 -0
  100. data/test/fixtures/quo_vadis/mailer/email_change_notification.text +8 -0
  101. data/test/fixtures/quo_vadis/mailer/identifier_change_notification.text +8 -0
  102. data/test/fixtures/quo_vadis/mailer/password_change_notification.text +8 -0
  103. data/test/fixtures/quo_vadis/mailer/password_reset_notification.text +8 -0
  104. data/test/fixtures/quo_vadis/mailer/recovery_codes_generation_notification.text +8 -0
  105. data/test/fixtures/quo_vadis/mailer/reset_password.text +4 -0
  106. data/test/fixtures/quo_vadis/mailer/totp_reuse_notification.text +6 -0
  107. data/test/fixtures/quo_vadis/mailer/totp_setup_notification.text +8 -0
  108. data/test/fixtures/quo_vadis/mailer/twofa_deactivated_notification.text +8 -0
  109. data/test/integration/account_confirmation_test.rb +145 -0
  110. data/test/integration/controller_test.rb +280 -0
  111. data/test/integration/logging_test.rb +235 -0
  112. data/test/integration/password_change_test.rb +93 -0
  113. data/test/integration/password_login_test.rb +125 -0
  114. data/test/integration/password_reset_test.rb +136 -0
  115. data/test/integration/recovery_codes_test.rb +48 -0
  116. data/test/integration/sessions_test.rb +86 -0
  117. data/test/integration/sign_up_test.rb +26 -12
  118. data/test/integration/totps_test.rb +96 -0
  119. data/test/integration/twofa_test.rb +82 -0
  120. data/test/mailers/mailer_test.rb +200 -0
  121. data/test/models/account_test.rb +34 -0
  122. data/test/models/crypt_test.rb +22 -0
  123. data/test/models/log_test.rb +16 -0
  124. data/test/models/mask_ip_test.rb +27 -0
  125. data/test/models/model_test.rb +66 -0
  126. data/test/models/password_test.rb +163 -0
  127. data/test/models/recovery_code_test.rb +54 -0
  128. data/test/models/session_test.rb +67 -0
  129. data/test/models/token_test.rb +70 -0
  130. data/test/models/totp_test.rb +68 -0
  131. data/test/quo_vadis_test.rb +39 -3
  132. data/test/test_helper.rb +42 -70
  133. metadata +123 -207
  134. data/app/controllers/controller_mixin.rb +0 -109
  135. data/app/mailers/quo_vadis/notifier.rb +0 -30
  136. data/app/models/model_mixin.rb +0 -128
  137. data/lib/generators/quo_vadis/templates/migration.rb.erb +0 -18
  138. data/lib/generators/quo_vadis/templates/quo_vadis.rb.erb +0 -96
  139. data/test/dummy/.gitignore +0 -2
  140. data/test/dummy/app/helpers/application_helper.rb +0 -2
  141. data/test/dummy/app/helpers/articles_helper.rb +0 -2
  142. data/test/dummy/app/views/articles/new.html.erb +0 -11
  143. data/test/dummy/app/views/layouts/sessions.html.erb +0 -3
  144. data/test/dummy/app/views/quo_vadis/notifier/change_password.text.erb +0 -9
  145. data/test/dummy/app/views/quo_vadis/notifier/invite.text.erb +0 -8
  146. data/test/dummy/app/views/sessions/edit.html.erb +0 -11
  147. data/test/dummy/app/views/sessions/forgotten.html.erb +0 -13
  148. data/test/dummy/app/views/sessions/invite.html.erb +0 -31
  149. data/test/dummy/app/views/sessions/new.html.erb +0 -15
  150. data/test/dummy/config/environments/development.rb +0 -26
  151. data/test/dummy/config/environments/production.rb +0 -49
  152. data/test/dummy/config/environments/test.rb +0 -37
  153. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  154. data/test/dummy/config/initializers/inflections.rb +0 -10
  155. data/test/dummy/config/initializers/mime_types.rb +0 -5
  156. data/test/dummy/config/initializers/rack_patch.rb +0 -16
  157. data/test/dummy/config/initializers/secret_token.rb +0 -7
  158. data/test/dummy/config/initializers/session_store.rb +0 -8
  159. data/test/dummy/config/locales/en.yml +0 -5
  160. data/test/dummy/config/locales/quo_vadis.en.yml +0 -21
  161. data/test/dummy/db/migrate/20110124125037_create_users.rb +0 -13
  162. data/test/dummy/db/migrate/20110124131535_create_articles.rb +0 -14
  163. data/test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb +0 -18
  164. data/test/dummy/db/migrate/20111004112209_create_people.rb +0 -13
  165. data/test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb +0 -18
  166. data/test/dummy/public/404.html +0 -26
  167. data/test/dummy/public/422.html +0 -26
  168. data/test/dummy/public/500.html +0 -26
  169. data/test/dummy/public/javascripts/application.js +0 -2
  170. data/test/dummy/public/javascripts/controls.js +0 -965
  171. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  172. data/test/dummy/public/javascripts/effects.js +0 -1123
  173. data/test/dummy/public/javascripts/prototype.js +0 -6001
  174. data/test/dummy/public/javascripts/rails.js +0 -175
  175. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  176. data/test/dummy/script/rails +0 -6
  177. data/test/integration/activation_test.rb +0 -108
  178. data/test/integration/authenticate_test.rb +0 -39
  179. data/test/integration/blocked_test.rb +0 -23
  180. data/test/integration/config_test.rb +0 -118
  181. data/test/integration/cookie_test.rb +0 -67
  182. data/test/integration/csrf_test.rb +0 -41
  183. data/test/integration/forgotten_test.rb +0 -93
  184. data/test/integration/helper_test.rb +0 -18
  185. data/test/integration/locale_test.rb +0 -197
  186. data/test/integration/navigation_test.rb +0 -7
  187. data/test/integration/sign_in_person_test.rb +0 -26
  188. data/test/integration/sign_in_test.rb +0 -24
  189. data/test/integration/sign_out_test.rb +0 -20
  190. data/test/support/integration_case.rb +0 -11
  191. data/test/unit/user_test.rb +0 -75
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QuoVadis
2
- VERSION = '1.4.0'
4
+ VERSION = '2.0.2'
3
5
  end
data/quo_vadis.gemspec CHANGED
@@ -1,31 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'quo_vadis/version'
1
+ # frozen_string_literal: true
4
2
 
5
- Gem::Specification.new do |s|
6
- s.name = 'quo_vadis'
7
- s.version = QuoVadis::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Andy Stewart']
10
- s.email = ['boss@airbladesoftware.com']
11
- s.homepage = 'https://github.com/airblade/quo_vadis'
12
- s.summary = 'Simple username/password authentication for Rails 3.'
13
- s.description = s.summary
3
+ require_relative 'lib/quo_vadis/version'
14
4
 
15
- s.rubyforge_project = 'quo_vadis'
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'quo_vadis'
7
+ spec.version = QuoVadis::VERSION
8
+ spec.authors = ['Andy Stewart']
9
+ spec.email = ['boss@airbladesoftware.com']
16
10
 
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ['lib']
11
+ spec.summary = 'Multifactor authentication for Rails 6.'
12
+ spec.homepage = 'https://github.com/airblade/quo_vadis'
13
+ spec.license = 'MIT'
21
14
 
22
- s.add_dependency 'rails', '> 3.0.4', '< 5'
23
- s.add_dependency 'bcrypt-ruby', '~> 3.0.0'
15
+ # spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
24
16
 
25
- # s.add_development_dependency 'rails', '~> 3.0.4' # so we can test CSRF protection
26
- s.add_development_dependency 'sqlite3'
27
- s.add_development_dependency 'capybara', '~>1.1'
28
- s.add_development_dependency 'launchy'
29
- s.add_development_dependency 'rake'
30
- s.add_development_dependency 'test-unit', '~> 3.0'
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0")
19
+ end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'rails', '>= 6'
23
+ spec.add_dependency 'bcrypt', '~> 3.1.7'
24
+ spec.add_dependency 'rotp', '>= 6'
25
+ spec.add_dependency 'rqrcode', '~> 2.0'
31
26
  end
@@ -0,0 +1 @@
1
+ Only authenticated users can view articles.
data/test/dummy/Rakefile CHANGED
@@ -1,7 +1,3 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
1
+ require_relative 'config/application'
3
2
 
4
- require File.expand_path('../config/application', __FILE__)
5
- require 'rake'
6
-
7
- Dummy::Application.load_tasks
3
+ Rails.application.load_tasks
@@ -1,3 +1,2 @@
1
1
  class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
2
  end
@@ -1,20 +1,17 @@
1
1
  class ArticlesController < ApplicationController
2
- before_filter :authenticate, :except => [:index, :show]
2
+ before_action :require_authentication, except: :index
3
+ before_action :require_two_factor_authentication, only: :very_secret
3
4
 
4
5
  def index
5
- @articles = Article.all
6
6
  end
7
7
 
8
- def new
9
- @article = Article.new
8
+ def secret
10
9
  end
11
10
 
12
- def create
13
- @article = Article.new params[:article]
14
- if @article.save
15
- redirect_to :action => 'index'
16
- else
17
- render 'new'
18
- end
11
+ def also_secret
19
12
  end
13
+
14
+ def very_secret
15
+ end
16
+
20
17
  end
@@ -0,0 +1,42 @@
1
+ # To test sign-ups with confirmation (activation / verification)
2
+ class SignUpsController < ApplicationController
3
+
4
+ around_action :toggle_confirmation
5
+
6
+ def new
7
+ @user = User.new
8
+ end
9
+
10
+
11
+ def create
12
+ @user = User.new user_params
13
+ if @user.save
14
+ if QuoVadis.accounts_require_confirmation
15
+ request_confirmation @user
16
+ redirect_to quo_vadis.confirmations_path
17
+ else
18
+ redirect_to articles_path
19
+ end
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def show
26
+ @user = User.find params[:id]
27
+ end
28
+
29
+ private
30
+
31
+ def user_params
32
+ params.require(:user).permit(:name, :email, :password, :password_confirmation)
33
+ end
34
+
35
+ def toggle_confirmation
36
+ QuoVadis.accounts_require_confirmation true
37
+ yield
38
+ ensure
39
+ QuoVadis.accounts_require_confirmation false
40
+ end
41
+
42
+ end
@@ -1,17 +1,25 @@
1
- class UsersController < ActionController::Base
1
+ # To test creating users without activation
2
+ class UsersController < ApplicationController
2
3
 
3
4
  def new
4
5
  @user = User.new
5
6
  end
6
7
 
7
8
  def create
8
- @user = User.new params[:user]
9
+ @user = User.new user_params
9
10
  if @user.save
10
- flash[:notice] = 'You have signed up!'
11
- sign_in @user # <-- Quo Vadis sign-in hook
11
+ # NOTE to login the user here, do this:
12
+ # login @user, true
13
+ redirect_to articles_path
12
14
  else
13
- render 'new'
15
+ render :new
14
16
  end
15
17
  end
16
18
 
19
+ private
20
+
21
+ def user_params
22
+ params.require(:user).permit(:name, :email, :password, :password_confirmation)
23
+ end
24
+
17
25
  end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,2 +1,3 @@
1
- class Article < ActiveRecord::Base
1
+ class Article < ApplicationRecord
2
+ validates :title, presence: true
2
3
  end
@@ -1,3 +1,6 @@
1
- class Person < ActiveRecord::Base
2
- authenticates
1
+ class Person < ApplicationRecord
2
+ validates :username, presence: true, uniqueness: {case_sensitive: false}
3
+ validates :email, presence: true, uniqueness: {case_sensitive: false}
4
+
5
+ authenticates identifier: :username
3
6
  end
@@ -1,3 +1,6 @@
1
- class User < ActiveRecord::Base
1
+ class User < ApplicationRecord
2
+ validates :name, presence: true
3
+ validates :email, presence: true, uniqueness: {case_sensitive: false}
4
+
2
5
  authenticates
3
6
  end
@@ -0,0 +1 @@
1
+ <p>Also-secret Articles</p>
@@ -1 +1 @@
1
- <h1>Articles</h1>
1
+ <p>Public Articles</p>
@@ -0,0 +1 @@
1
+ <p>Secret Articles</p>
@@ -0,0 +1,2 @@
1
+ <p>Very Secret Articles</p>
2
+
@@ -1,30 +1,46 @@
1
- <!DOCTYPE html>
2
1
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= csrf_meta_tag %>
6
- </head>
7
- <body>
8
-
9
- <div id='topnav'>
10
- <% if authenticated? %>
11
- You are signed in as
12
- <% if defined?(current_user) %>
13
- <%= current_user.name %>.
14
- <% elsif defined?(current_person) %>
15
- <%= current_person.name %>.
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <%= csrf_meta_tags %>
5
+ <style>
6
+ nav {
7
+ border-bottom: 1px solid #ddd;
8
+ padding: 10px 0;
9
+ }
10
+ nav span {
11
+ margin: 0 5px;
12
+ }
13
+ main {
14
+ margin-top: 20px;
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <nav>
20
+ <% if logged_in? %>
21
+ <span>Logged in as: <%= authenticated_model.email %></span>
22
+ <span><%= link_to 'Sessions', quo_vadis.sessions_path %></span>
23
+ <span><%= link_to 'Change password', quo_vadis.edit_password_path %></span>
24
+ <span><%= link_to '2FA', quo_vadis.twofa_path %></span>
25
+ <span><%= link_to 'Logs', quo_vadis.logs_path %></span>
26
+ <span><%= button_to 'Log out', quo_vadis.logout_path, method: :delete, form: {style: 'display:inline-block'} %></span>
27
+ <% else %>
28
+ <span><%= link_to 'Add user (without confirmation)', main_app.new_user_path %></span>
29
+ <span><%= link_to 'Sign up (with confirmation)', main_app.new_sign_up_path %></span>
30
+ <span><%= link_to 'Log in', quo_vadis.login_path %></span>
16
31
  <% end %>
17
- <%= link_to 'Sign out', sign_out_path %>
18
- <% else %>
19
- <%= link_to 'Sign in', sign_in_path %>
20
- <% end %>
21
- </div>
22
-
23
- <% flash.each do |key, value| %>
24
- <div class='flash <%= key %>'><%= value %></div>
25
- <% end %>
32
+ </nav>
26
33
 
27
- <%= yield %>
34
+ <main>
35
+ <section>
36
+ <% %w[notice alert].select { |k| flash.key? k }.each do |k| %>
37
+ <div class="flash flash-<%= k %>">
38
+ <%= flash[k] %>
39
+ </div>
40
+ <% end %>
41
+ </section>
28
42
 
29
- </body>
43
+ <%= yield %>
44
+ </main>
45
+ </body>
30
46
  </html>
@@ -0,0 +1,10 @@
1
+ <h1>Confirm account</h1>
2
+
3
+ <%= form_with url: confirmation_path(params[:token]), method: :put do |f| %>
4
+
5
+ <p>
6
+ <label>Please click the button to confirm your account:</label>
7
+ <%= f.submit %>
8
+ </p>
9
+
10
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h1>Account confirmation: change email</h1>
2
+
3
+ <p>Please update your email address.</p>
4
+
5
+ <%= form_with url: update_email_confirmations_path, method: :put do |f| %>
6
+ <p>
7
+ <%= f.label :email %>
8
+ <%= f.text_field :email, value: @email, inputmode: 'email', autocomplete: 'email' %>
9
+ </p>
10
+
11
+ <p>
12
+ <%= f.submit 'Update my email address and send me a new confirmation email' %>
13
+ </p>
14
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h1>Account confirmation</h1>
2
+
3
+ <% if @account %>
4
+ <p>We have sent an email to <%= @account.model.email %>.</p>
5
+
6
+ <p>Wrong address? <%= link_to 'Change it', edit_email_confirmations_path %>.</p>
7
+
8
+ <p>Didn't receive it? <%= button_to 'Get another one', resend_confirmations_path %></p>
9
+
10
+ <% else %>
11
+ <p>We have sent an email to you.</p>
12
+
13
+ <p><%= link_to 'Request a new email', new_confirmation_path %></p>
14
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <h1>Resend confirmation instructions</h1>
2
+
3
+ <%# Note that in this example the User identifier is :email. %>
4
+
5
+ <p>If you didn't receive the confirmation email, please enter your email address and we'll send you another one.</p>
6
+
7
+ <%= form_with url: confirmations_path, method: :post do |f| %>
8
+ <p>
9
+ <%= f.label :email %>
10
+ <%= f.text_field :email, inputmode: 'email', autocomplete: 'email' %>
11
+ </p>
12
+
13
+ <p>
14
+ <%= f.submit %>
15
+ </p>
16
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <h1>Logs</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Action</th>
7
+ <th>IP</th>
8
+ <th>Metadata</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @logs.each do |log| %>
13
+ <tr>
14
+ <td><%= log.action %></td>
15
+ <td><%= log.ip %></td>
16
+ <td><%= log.metadata.empty? ? '' : log.metadata.map {|k,v| "#{k}: #{v}"}.join(', ') %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+
22
+ <% if @prev_page %>
23
+ <%= link_to 'Newer', logs_path(page: @prev_page) %>
24
+ <% end %>
25
+
26
+ <% if @next_page %>
27
+ <%= link_to 'Older', logs_path(page: @next_page) %>
28
+ <% end %>
@@ -0,0 +1,4 @@
1
+ You can confirm your account here:
2
+
3
+ <%= @url %>
4
+
@@ -0,0 +1,8 @@
1
+ Your email address was changed just now.
2
+
3
+ Location: <%= @ip %>
4
+ Time: <%= @timestamp.strftime '%e %B at %H:%M (%Z)' %>
5
+
6
+ If this was you, you don't need to do anything.
7
+
8
+ If this wasn't you, please let us know.
@@ -0,0 +1,8 @@
1
+ Your <%= @identifier %> was changed just now.
2
+
3
+ Location: <%= @ip %>
4
+ Time: <%= @timestamp.strftime '%e %B at %H:%M (%Z)' %>
5
+
6
+ If this was you, you don't need to do anything.
7
+
8
+ If this wasn't you, please let us know.
@@ -0,0 +1,8 @@
1
+ Your password was changed just now.
2
+
3
+ Location: <%= @ip %>
4
+ Time: <%= @timestamp.strftime '%e %B at %H:%M (%Z)' %>
5
+
6
+ If this was you, you don't need to do anything.
7
+
8
+ If this wasn't you, please let us know.
@@ -0,0 +1,8 @@
1
+ Your password was reset just now.
2
+
3
+ Location: <%= @ip %>
4
+ Time: <%= @timestamp.strftime '%e %B at %H:%M (%Z)' %>
5
+
6
+ If this was you, you don't need to do anything.
7
+
8
+ If this wasn't you, please let us know.
@@ -0,0 +1,8 @@
1
+ Recovery codes for two-factor authentication were generated for your account just now.
2
+
3
+ Location: <%= @ip %>
4
+ Time: <%= @timestamp.strftime '%e %B at %H:%M (%Z)' %>
5
+
6
+ If this was you, you don't need to do anything.
7
+
8
+ If this wasn't you, please let us know.