rodauth-rails 0.17.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +80 -0
- data/README.md +224 -548
- data/lib/generators/rodauth/install_generator.rb +40 -35
- data/lib/generators/rodauth/migration/base.erb +8 -2
- data/lib/generators/rodauth/migration_generator.rb +9 -2
- data/lib/generators/rodauth/templates/INSTRUCTIONS +40 -0
- data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +36 -19
- data/lib/generators/rodauth/templates/app/misc/rodauth_app.rb +38 -0
- data/lib/generators/rodauth/templates/app/{lib/rodauth_app.rb → misc/rodauth_main.rb} +10 -53
- data/lib/generators/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb +7 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_form.html.erb +26 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_form_footer.html.erb +7 -6
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_form_header.html.erb +3 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/add_recovery_codes.html.erb +7 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/change_login.html.erb +29 -6
- data/lib/generators/rodauth/templates/app/views/rodauth/change_password.html.erb +29 -6
- data/lib/generators/rodauth/templates/app/views/rodauth/close_account.html.erb +15 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/confirm_password.html.erb +13 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/create_account.html.erb +37 -7
- data/lib/generators/rodauth/templates/app/views/rodauth/email_auth.html.erb +7 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/login.html.erb +5 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/logout.html.erb +16 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/multi_phase_login.html.erb +5 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_auth.html.erb +17 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_disable.html.erb +15 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/otp_setup.html.erb +30 -10
- data/lib/generators/rodauth/templates/app/views/rodauth/recovery_auth.html.erb +13 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/recovery_codes.html.erb +15 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/remember.html.erb +14 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password.html.erb +21 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/reset_password_request.html.erb +19 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_auth.html.erb +17 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_confirm.html.erb +17 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_disable.html.erb +15 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_request.html.erb +7 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/sms_setup.html.erb +25 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_auth.html.erb +5 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_disable.html.erb +15 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/two_factor_manage.html.erb +17 -15
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account.html.erb +17 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/unlock_account_request.html.erb +11 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account.html.erb +23 -5
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_account_resend.html.erb +19 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/verify_login_change.html.erb +7 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_auth.html.erb +13 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_remove.html.erb +21 -9
- data/lib/generators/rodauth/templates/app/views/rodauth/webauthn_setup.html.erb +21 -9
- data/lib/generators/rodauth/templates/app/views/rodauth_mailer/email_auth.text.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth_mailer/reset_password.text.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth_mailer/unlock_account.text.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth_mailer/verify_account.text.erb +1 -1
- data/lib/generators/rodauth/templates/app/views/rodauth_mailer/verify_login_change.text.erb +3 -3
- data/lib/generators/rodauth/views_generator.rb +55 -93
- data/lib/rodauth/rails/app.rb +5 -4
- data/lib/rodauth/rails/auth.rb +1 -16
- data/lib/rodauth/rails/controller_methods.rb +1 -1
- data/lib/rodauth/rails/feature/csrf.rb +15 -4
- data/lib/rodauth/rails/feature/internal_request.rb +22 -20
- data/lib/rodauth/rails/feature/render.rb +9 -1
- data/lib/rodauth/rails/railtie.rb +4 -2
- data/lib/rodauth/rails/tasks.rake +2 -2
- data/lib/rodauth/rails/version.rb +1 -1
- data/lib/rodauth/rails.rb +16 -20
- data/rodauth-rails.gemspec +2 -2
- metadata +9 -23
- data/lib/generators/rodauth/templates/app/views/rodauth/_field.html.erb +0 -10
- data/lib/generators/rodauth/templates/app/views/rodauth/_field_error.html.erb +0 -3
- data/lib/generators/rodauth/templates/app/views/rodauth/_global_logout_field.html.erb +0 -6
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_confirm_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_display.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_login_hidden_field.html.erb +0 -1
- data/lib/generators/rodauth/templates/app/views/rodauth/_new_password_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_otp_auth_code_field.html.erb +0 -8
- data/lib/generators/rodauth/templates/app/views/rodauth/_password_confirm_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_password_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_recovery_code_field.html.erb +0 -4
- data/lib/generators/rodauth/templates/app/views/rodauth/_recovery_codes_form.html.erb +0 -6
- data/lib/generators/rodauth/templates/app/views/rodauth/_sms_code_field.html.erb +0 -8
- data/lib/generators/rodauth/templates/app/views/rodauth/_sms_phone_field.html.erb +0 -8
- data/lib/generators/rodauth/templates/app/views/rodauth/_submit.html.erb +0 -3
@@ -10,6 +10,20 @@ module Rodauth
|
|
10
10
|
include ::ActiveRecord::Generators::Migration
|
11
11
|
include MigrationHelpers
|
12
12
|
|
13
|
+
if RUBY_ENGINE == "jruby"
|
14
|
+
SEQUEL_ADAPTERS = {
|
15
|
+
"sqlite3" => "sqlite",
|
16
|
+
"oracle_enhanced" => "oracle", # https://github.com/rsim/oracle-enhanced
|
17
|
+
"sqlserver" => "mssql",
|
18
|
+
}
|
19
|
+
else
|
20
|
+
SEQUEL_ADAPTERS = {
|
21
|
+
"sqlite3" => "sqlite",
|
22
|
+
"oracle_enhanced" => "oracle", # https://github.com/rsim/oracle-enhanced
|
23
|
+
"sqlserver" => "tinytds", # https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
13
27
|
MAILER_VIEWS = %w[
|
14
28
|
email_auth
|
15
29
|
password_changed
|
@@ -26,7 +40,7 @@ module Rodauth
|
|
26
40
|
class_option :jwt, type: :boolean, desc: "Configure JWT support"
|
27
41
|
|
28
42
|
def create_rodauth_migration
|
29
|
-
return unless defined?(ActiveRecord::
|
43
|
+
return unless defined?(ActiveRecord::Railtie)
|
30
44
|
|
31
45
|
migration_template "db/migrate/create_rodauth.rb"
|
32
46
|
end
|
@@ -36,14 +50,15 @@ module Rodauth
|
|
36
50
|
end
|
37
51
|
|
38
52
|
def create_sequel_initializer
|
39
|
-
return unless defined?(ActiveRecord::
|
53
|
+
return unless defined?(ActiveRecord::Railtie)
|
40
54
|
return if defined?(Sequel) && !Sequel::DATABASES.empty?
|
41
55
|
|
42
56
|
template "config/initializers/sequel.rb"
|
43
57
|
end
|
44
58
|
|
45
59
|
def create_rodauth_app
|
46
|
-
template "app/
|
60
|
+
template "app/misc/rodauth_app.rb"
|
61
|
+
template "app/misc/rodauth_main.rb"
|
47
62
|
end
|
48
63
|
|
49
64
|
def create_rodauth_controller
|
@@ -51,7 +66,7 @@ module Rodauth
|
|
51
66
|
end
|
52
67
|
|
53
68
|
def create_account_model
|
54
|
-
return unless defined?(ActiveRecord::
|
69
|
+
return unless defined?(ActiveRecord::Railtie)
|
55
70
|
|
56
71
|
template "app/models/account.rb"
|
57
72
|
end
|
@@ -60,52 +75,42 @@ module Rodauth
|
|
60
75
|
template "app/mailers/rodauth_mailer.rb"
|
61
76
|
|
62
77
|
MAILER_VIEWS.each do |view|
|
63
|
-
|
78
|
+
copy_file "app/views/rodauth_mailer/#{view}.text.erb"
|
64
79
|
end
|
65
80
|
end
|
66
81
|
|
82
|
+
def show_instructions
|
83
|
+
readme "INSTRUCTIONS" if behavior == :invoke
|
84
|
+
end
|
85
|
+
|
67
86
|
private
|
68
87
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
sequel_adapter
|
74
|
-
end
|
88
|
+
def migration_features
|
89
|
+
features = [:base, :reset_password, :verify_account, :verify_login_change]
|
90
|
+
features << :remember unless jwt?
|
91
|
+
features
|
75
92
|
end
|
76
93
|
|
77
|
-
def
|
78
|
-
|
79
|
-
when "sqlite3" then "sqlite"
|
80
|
-
when "oracle_enhanced" then "oracle" # https://github.com/rsim/oracle-enhanced
|
81
|
-
when "sqlserver" then "tinytds" # https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
82
|
-
else
|
83
|
-
activerecord_adapter
|
84
|
-
end
|
94
|
+
def json?
|
95
|
+
options[:json] || api_only? && session_store? && !options[:jwt]
|
85
96
|
end
|
86
97
|
|
87
|
-
def
|
88
|
-
|
89
|
-
when "sqlite3" then "sqlite"
|
90
|
-
when "oracle_enhanced" then "oracle" # https://github.com/rsim/oracle-enhanced
|
91
|
-
when "sqlserver" then "mssql"
|
92
|
-
else
|
93
|
-
activerecord_adapter
|
94
|
-
end
|
98
|
+
def jwt?
|
99
|
+
options[:jwt] || api_only? && !session_store? && !options[:json]
|
95
100
|
end
|
96
101
|
|
97
|
-
def
|
98
|
-
|
102
|
+
def session_store?
|
103
|
+
!!::Rails.application.config.session_store
|
99
104
|
end
|
100
105
|
|
101
|
-
def
|
102
|
-
|
106
|
+
def api_only?
|
107
|
+
Rodauth::Rails.api_only?
|
103
108
|
end
|
104
109
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
110
|
+
def sequel_uri_scheme
|
111
|
+
scheme = SEQUEL_ADAPTERS[activerecord_adapter] || activerecord_adapter
|
112
|
+
scheme = "jdbc:#{scheme}" if RUBY_ENGINE == "jruby"
|
113
|
+
scheme
|
109
114
|
end
|
110
115
|
end
|
111
116
|
end
|
@@ -5,11 +5,17 @@ enable_extension "citext"
|
|
5
5
|
create_table :accounts<%= primary_key_type %> do |t|
|
6
6
|
<% case activerecord_adapter -%>
|
7
7
|
<% when "postgresql" -%>
|
8
|
-
t.citext :email, null: false
|
8
|
+
t.citext :email, null: false
|
9
9
|
<% else -%>
|
10
|
-
t.string :email, null: false
|
10
|
+
t.string :email, null: false
|
11
11
|
<% end -%>
|
12
12
|
t.string :status, null: false, default: "unverified"
|
13
|
+
<% case activerecord_adapter -%>
|
14
|
+
<% when "postgresql", "sqlite3" -%>
|
15
|
+
t.index :email, unique: true, where: "status IN ('unverified', 'verified')"
|
16
|
+
<% else -%>
|
17
|
+
t.index :email, unique: true
|
18
|
+
<% end -%>
|
13
19
|
end
|
14
20
|
|
15
21
|
# Used if storing password hashes in a separate table (default)
|
@@ -16,16 +16,23 @@ module Rodauth
|
|
16
16
|
desc: "Rodauth features to create tables for (otp, sms_codes, single_session, account_expiration etc.)",
|
17
17
|
default: %w[]
|
18
18
|
|
19
|
+
class_option :name, optional: true, type: :string,
|
20
|
+
desc: "Name of the generated migration file"
|
21
|
+
|
19
22
|
def create_rodauth_migration
|
20
|
-
return unless defined?(ActiveRecord::
|
23
|
+
return unless defined?(ActiveRecord::Railtie)
|
21
24
|
return if features.empty?
|
22
25
|
|
23
|
-
migration_template "db/migrate/create_rodauth.rb", "
|
26
|
+
migration_template "db/migrate/create_rodauth.rb", "#{migration_name}.rb"
|
24
27
|
end
|
25
28
|
|
26
29
|
def migration_features
|
27
30
|
features
|
28
31
|
end
|
32
|
+
|
33
|
+
def migration_name
|
34
|
+
options[:name] || "create_rodauth_#{features.join("_")}"
|
35
|
+
end
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Depending on your application's configuration some manual setup may be required:
|
4
|
+
|
5
|
+
1. Ensure you have defined default url options in your environments files. Here
|
6
|
+
is an example of default_url_options appropriate for a development environment
|
7
|
+
in config/environments/development.rb:
|
8
|
+
|
9
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
10
|
+
|
11
|
+
In production, :host should be set to the actual host of your application.
|
12
|
+
|
13
|
+
* Required for all applications. *
|
14
|
+
|
15
|
+
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
16
|
+
For example:
|
17
|
+
|
18
|
+
root to: "home#index"
|
19
|
+
|
20
|
+
* Not required for API-only Applications *
|
21
|
+
|
22
|
+
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
23
|
+
For example:
|
24
|
+
|
25
|
+
<% if notice %>
|
26
|
+
<div class="alert alert-success"><%= notice %></div>
|
27
|
+
<% end %>
|
28
|
+
<% if alert %>
|
29
|
+
<div class="alert alert-danger"><%= alert %></div>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
* Not required for API-only Applications *
|
33
|
+
|
34
|
+
4. You can copy Rodauth views (for customization) to your app by running:
|
35
|
+
|
36
|
+
rails g rodauth:views
|
37
|
+
|
38
|
+
* Not required *
|
39
|
+
|
40
|
+
===============================================================================
|
@@ -1,37 +1,54 @@
|
|
1
1
|
class RodauthMailer < ApplicationMailer
|
2
|
-
def verify_account(
|
3
|
-
@email_link =
|
2
|
+
def verify_account(account_id, key)
|
3
|
+
@email_link = rodauth.verify_account_url(key: email_token(account_id, key))
|
4
|
+
@account = Account.find(account_id)
|
4
5
|
|
5
|
-
mail to:
|
6
|
+
mail to: @account.email, subject: rodauth.verify_account_email_subject
|
6
7
|
end
|
7
8
|
|
8
|
-
def reset_password(
|
9
|
-
@email_link =
|
9
|
+
def reset_password(account_id, key)
|
10
|
+
@email_link = rodauth.reset_password_url(key: email_token(account_id, key))
|
11
|
+
@account = Account.find(account_id)
|
10
12
|
|
11
|
-
mail to:
|
13
|
+
mail to: @account.email, subject: rodauth.reset_password_email_subject
|
12
14
|
end
|
13
15
|
|
14
|
-
def verify_login_change(
|
16
|
+
def verify_login_change(account_id, old_login, new_login, key)
|
15
17
|
@old_login = old_login
|
16
18
|
@new_login = new_login
|
17
|
-
@email_link =
|
19
|
+
@email_link = rodauth.verify_login_change_url(key: email_token(account_id, key))
|
20
|
+
@account = Account.find(account_id)
|
18
21
|
|
19
|
-
mail to:
|
22
|
+
mail to: new_login, subject: rodauth.verify_login_change_email_subject
|
20
23
|
end
|
21
24
|
|
22
|
-
def password_changed(
|
23
|
-
|
25
|
+
def password_changed(account_id)
|
26
|
+
@account = Account.find(account_id)
|
27
|
+
|
28
|
+
mail to: @account.email, subject: rodauth.password_changed_email_subject
|
24
29
|
end
|
25
30
|
|
26
|
-
# def email_auth(
|
27
|
-
# @email_link =
|
28
|
-
#
|
29
|
-
|
31
|
+
# def email_auth(account_id, key)
|
32
|
+
# @email_link = rodauth.email_auth_url(key: email_token(account_id, key))
|
33
|
+
# @account = Account.find(account_id)
|
34
|
+
|
35
|
+
# mail to: @account.email, subject: rodauth.email_auth_email_subject
|
30
36
|
# end
|
31
37
|
|
32
|
-
# def unlock_account(
|
33
|
-
# @email_link =
|
34
|
-
#
|
35
|
-
|
38
|
+
# def unlock_account(account_id, key)
|
39
|
+
# @email_link = rodauth.unlock_account_url(key: email_token(account_id, key))
|
40
|
+
# @account = Account.find(account_id)
|
41
|
+
|
42
|
+
# mail to: @account.email, subject: rodauth.unlock_account_email_subject
|
36
43
|
# end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def email_token(account_id, key)
|
48
|
+
"#{account_id}_#{rodauth.compute_hmac(key)}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def rodauth(name = nil)
|
52
|
+
RodauthApp.rodauth(name).allocate
|
53
|
+
end
|
37
54
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class RodauthApp < Rodauth::Rails::App
|
2
|
+
# primary configuration
|
3
|
+
configure RodauthMain
|
4
|
+
|
5
|
+
# secondary configuration
|
6
|
+
# configure RodauthAdmin, :admin
|
7
|
+
|
8
|
+
route do |r|
|
9
|
+
<% unless jwt? -%>
|
10
|
+
rodauth.load_memory # autologin remembered users
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
r.rodauth # route rodauth requests
|
14
|
+
|
15
|
+
# ==> Authenticating Requests
|
16
|
+
# Call `rodauth.require_authentication` for requests that you want to
|
17
|
+
# require authentication for. Some examples:
|
18
|
+
#
|
19
|
+
# next if r.path.start_with?("/docs") # skip authentication for documentation pages
|
20
|
+
# next if session[:admin] # skip authentication for admins
|
21
|
+
#
|
22
|
+
# # authenticate /dashboard/* and /account/* requests
|
23
|
+
# if r.path.start_with?("/dashboard") || r.path.start_with?("/account")
|
24
|
+
# rodauth.require_authentication
|
25
|
+
# end
|
26
|
+
|
27
|
+
# ==> Secondary configurations
|
28
|
+
# r.on "admin" do
|
29
|
+
# r.rodauth(:admin)
|
30
|
+
#
|
31
|
+
# unless rodauth(:admin).logged_in?
|
32
|
+
# rodauth(:admin).require_http_basic_auth
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# break # allow the Rails app to handle other "/admin/*" requests
|
36
|
+
# end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
class
|
1
|
+
class RodauthMain < Rodauth::Rails::Auth
|
2
2
|
configure do
|
3
3
|
# List of authentication features that are loaded.
|
4
4
|
enable :create_account, :verify_account, :verify_account_grace_period,
|
5
5
|
:login, :logout<%= ", :remember" unless jwt? %><%= ", :json" if json? %><%= ", :jwt" if jwt? %>,
|
6
6
|
:reset_password, :change_password, :change_password_notify,
|
7
|
-
:change_login, :verify_login_change,
|
8
|
-
:close_account
|
7
|
+
:change_login, :verify_login_change, :close_account
|
9
8
|
|
10
9
|
# See the Rodauth documentation for the list of available config options:
|
11
10
|
# http://rodauth.jeremyevans.net/documentation.html
|
@@ -52,7 +51,7 @@ class RodauthApp < Rodauth::Rails::App
|
|
52
51
|
# reset_password_autologin? true
|
53
52
|
|
54
53
|
# Delete the account record when the user has closed their account.
|
55
|
-
delete_account_on_close? true
|
54
|
+
# delete_account_on_close? true
|
56
55
|
|
57
56
|
# Redirect to the app from login and registration pages if already logged in.
|
58
57
|
# already_logged_in { redirect login_redirect }
|
@@ -60,22 +59,22 @@ class RodauthApp < Rodauth::Rails::App
|
|
60
59
|
# ==> Emails
|
61
60
|
# Use a custom mailer for delivering authentication emails.
|
62
61
|
create_reset_password_email do
|
63
|
-
RodauthMailer.reset_password(
|
62
|
+
RodauthMailer.reset_password(account_id, reset_password_key_value)
|
64
63
|
end
|
65
64
|
create_verify_account_email do
|
66
|
-
RodauthMailer.verify_account(
|
65
|
+
RodauthMailer.verify_account(account_id, verify_account_key_value)
|
67
66
|
end
|
68
|
-
create_verify_login_change_email do |
|
69
|
-
RodauthMailer.verify_login_change(
|
67
|
+
create_verify_login_change_email do |_login|
|
68
|
+
RodauthMailer.verify_login_change(account_id, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_key_value)
|
70
69
|
end
|
71
70
|
create_password_changed_email do
|
72
|
-
RodauthMailer.password_changed(
|
71
|
+
RodauthMailer.password_changed(account_id)
|
73
72
|
end
|
74
73
|
# create_email_auth_email do
|
75
|
-
# RodauthMailer.email_auth(
|
74
|
+
# RodauthMailer.email_auth(account_id, email_auth_key_value)
|
76
75
|
# end
|
77
76
|
# create_unlock_account_email do
|
78
|
-
# RodauthMailer.unlock_account(
|
77
|
+
# RodauthMailer.unlock_account(account_id, unlock_account_key_value)
|
79
78
|
# end
|
80
79
|
send_email do |email|
|
81
80
|
# queue email delivery on the mailer after the transaction commits
|
@@ -153,46 +152,4 @@ class RodauthApp < Rodauth::Rails::App
|
|
153
152
|
# remember_deadline_interval Hash[days: 30]
|
154
153
|
<% end -%>
|
155
154
|
end
|
156
|
-
|
157
|
-
# ==> Secondary configurations
|
158
|
-
# configure(:admin) do
|
159
|
-
# # ... enable features ...
|
160
|
-
# prefix "/admin"
|
161
|
-
# session_key_prefix "admin_"
|
162
|
-
# # remember_cookie_key "_admin_remember" # if using remember feature
|
163
|
-
#
|
164
|
-
# # search views in `app/views/admin/rodauth` directory
|
165
|
-
# rails_controller { Admin::RodauthController }
|
166
|
-
# end
|
167
|
-
|
168
|
-
route do |r|
|
169
|
-
<% unless jwt? -%>
|
170
|
-
rodauth.load_memory # autologin remembered users
|
171
|
-
|
172
|
-
<% end -%>
|
173
|
-
r.rodauth # route rodauth requests
|
174
|
-
|
175
|
-
# ==> Authenticating Requests
|
176
|
-
# Call `rodauth.require_authentication` for requests that you want to
|
177
|
-
# require authentication for. Some examples:
|
178
|
-
#
|
179
|
-
# next if r.path.start_with?("/docs") # skip authentication for documentation pages
|
180
|
-
# next if session[:admin] # skip authentication for admins
|
181
|
-
#
|
182
|
-
# # authenticate /dashboard/* and /account/* requests
|
183
|
-
# if r.path.start_with?("/dashboard") || r.path.start_with?("/account")
|
184
|
-
# rodauth.require_authentication
|
185
|
-
# end
|
186
|
-
|
187
|
-
# ==> Secondary configurations
|
188
|
-
# r.on "admin" do
|
189
|
-
# r.rodauth(:admin)
|
190
|
-
#
|
191
|
-
# unless rodauth(:admin).logged_in?
|
192
|
-
# rodauth(:admin).require_http_basic_auth
|
193
|
-
# end
|
194
|
-
#
|
195
|
-
# break # allow the Rails app to handle other "/admin/*" requests
|
196
|
-
# end
|
197
|
-
end
|
198
155
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<%= form_with url: rodauth.email_auth_request_path, method: :post, data: { turbo: false } do |form| %>
|
2
|
+
<%= form.hidden_field rodauth.login_param, value: params[rodauth.login_param] %>
|
3
|
+
|
4
|
+
<div class="form-group mb-3">
|
5
|
+
<%= form.submit rodauth.email_auth_request_button, class: "btn btn-primary" %>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
@@ -1,9 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
<%= form_with url: rodauth.login_path, method: :post, data: { turbo: false } do |form| %>
|
2
|
+
<% if rodauth.skip_login_field_on_login? %>
|
3
|
+
<div class="form-group mb-3">
|
4
|
+
<%= form.label "login", rodauth.login_label, class: "form-label" %>
|
5
|
+
<%= form.email_field rodauth.login_param, value: params[rodauth.login_param], id: "login", readonly: true, class: "form-control-plaintext" %>
|
6
|
+
</div>
|
7
|
+
<% else %>
|
8
|
+
<div class="form-group mb-3">
|
9
|
+
<%= form.label "login", rodauth.login_label, class: "form-label" %>
|
10
|
+
<%= form.email_field rodauth.login_param, value: params[rodauth.login_param], id: "login", autocomplete: "email", required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.login_param)}", aria: ({ invalid: true, describedby: "login_error_message" } if rodauth.field_error(rodauth.login_param)) %>
|
11
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.login_param), class: "invalid-feedback", id: "login_error_message") if rodauth.field_error(rodauth.login_param) %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% unless rodauth.skip_password_field_on_login? %>
|
16
|
+
<div class="form-group mb-3">
|
17
|
+
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
18
|
+
<%= form.password_field rodauth.password_param, value: "", id: "password", autocomplete: rodauth.password_field_autocomplete_value, required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_param)}", aria: ({ invalid: true, describedby: "password_error_message" } if rodauth.field_error(rodauth.password_param)) %>
|
19
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_param), class: "invalid-feedback", id: "password_error_message") if rodauth.field_error(rodauth.password_param) %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<div class="form-group mb-3">
|
24
|
+
<%= form.submit rodauth.login_button, class: "btn btn-primary" %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% unless rodauth.login_form_footer_links.empty? %>
|
2
|
+
<%== rodauth.login_form_footer_links_heading %>
|
3
|
+
|
3
4
|
<ul>
|
4
|
-
|
5
|
-
<li
|
6
|
-
|
5
|
+
<% rodauth.login_form_footer_links.sort.each do |_, link, text| %>
|
6
|
+
<li><%= link_to text, link %></li>
|
7
|
+
<% end %>
|
7
8
|
</ul>
|
8
|
-
|
9
|
+
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
<% if rodauth.field_error(rodauth.password_param) && rodauth.features.include?(:reset_password) %>
|
2
|
+
<%= render template: "rodauth/reset_password_request", layout: false %>
|
3
|
+
<% end %>
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
<% content_for :title, rodauth.add_recovery_codes_page_title %>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
<pre id="recovery-codes"><%= rodauth.recovery_codes.map { |s| h(s) }.join("\n\n") %></pre>
|
4
|
+
|
5
|
+
<% if rodauth.can_add_recovery_codes? %>
|
6
|
+
<%== rodauth.add_recovery_codes_heading %>
|
7
|
+
<%= render template: "rodauth/recovery_codes", layout: false %>
|
8
|
+
<% end %>
|
@@ -1,6 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
<% content_for :title, rodauth.change_login_page_title %>
|
2
|
+
|
3
|
+
<%= form_with url: rodauth.change_login_path, method: :post, data: { turbo: false } do |form| %>
|
4
|
+
<div class="form-group mb-3">
|
5
|
+
<%= form.label "login", rodauth.login_label, class: "form-label" %>
|
6
|
+
<%= form.email_field rodauth.login_param, value: params[rodauth.login_param], id: "login", autocomplete: "email", required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.login_param)}", aria: ({ invalid: true, describedby: "login_error_message" } if rodauth.field_error(rodauth.login_param)) %>
|
7
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.login_param), class: "invalid-feedback", id: "login_error_message") if rodauth.field_error(rodauth.login_param) %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<% if rodauth.require_login_confirmation? %>
|
11
|
+
<div class="form-group mb-3">
|
12
|
+
<%= form.label "login-confirm", rodauth.login_confirm_label, class: "form-label" %>
|
13
|
+
<%= form.email_field rodauth.login_confirm_param, value: params[rodauth.login_confirm_param], id: "login-confirm", autocomplete: "email", required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.login_confirm_param)}", aria: ({ invalid: true, describedby: "login-confirm_error_message" } if rodauth.field_error(rodauth.login_confirm_param)) %>
|
14
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.login_confirm_param), class: "invalid-feedback", id: "login-confirm_error_message") if rodauth.field_error(rodauth.login_confirm_param) %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% if rodauth.change_login_requires_password? %>
|
19
|
+
<div class="form-group mb-3">
|
20
|
+
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
21
|
+
<%= form.password_field rodauth.password_param, value: "", id: "password", autocomplete: rodauth.password_field_autocomplete_value, required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_param)}", aria: ({ invalid: true, describedby: "password_error_message" } if rodauth.field_error(rodauth.password_param)) %>
|
22
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_param), class: "invalid-feedback", id: "password_error_message") if rodauth.field_error(rodauth.password_param) %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="form-group mb-3">
|
27
|
+
<%= form.submit rodauth.change_login_button, class: "btn btn-primary" %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
@@ -1,6 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
<% content_for :title, rodauth.change_password_page_title %>
|
2
|
+
|
3
|
+
<%= form_with url: rodauth.change_password_path, method: :post, data: { turbo: false } do |form| %>
|
4
|
+
<% if rodauth.change_password_requires_password? %>
|
5
|
+
<div class="form-group mb-3">
|
6
|
+
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
7
|
+
<%= form.password_field rodauth.password_param, value: "", id: "password", autocomplete: rodauth.password_field_autocomplete_value, required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_param)}", aria: ({ invalid: true, describedby: "password_error_message" } if rodauth.field_error(rodauth.password_param)) %>
|
8
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_param), class: "invalid-feedback", id: "password_error_message") if rodauth.field_error(rodauth.password_param) %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<div class="form-group mb-3">
|
13
|
+
<%= form.label "new-password", rodauth.new_password_label, class: "form-label" %>
|
14
|
+
<%= form.password_field rodauth.new_password_param, value: "", id: "new-password", autocomplete: "new-password", required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.new_password_param)}", aria: ({ invalid: true, describedby: "new-password_error_message" } if rodauth.field_error(rodauth.new_password_param)) %>
|
15
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.new_password_param), class: "invalid-feedback", id: "new-password_error_message") if rodauth.field_error(rodauth.new_password_param) %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<% if rodauth.require_password_confirmation? %>
|
19
|
+
<div class="form-group mb-3">
|
20
|
+
<%= form.label "password-confirm", rodauth.password_confirm_label, class: "form-label" %>
|
21
|
+
<%= form.password_field rodauth.password_confirm_param, value: "", id: "password-confirm", autocomplete: "new-password", required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_confirm_param)}", aria: ({ invalid: true, describedby: "password-confirm_error_message" } if rodauth.field_error(rodauth.password_confirm_param)) %>
|
22
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_confirm_param), class: "invalid-feedback", id: "password-confirm_error_message") if rodauth.field_error(rodauth.password_confirm_param) %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="form-group mb-3">
|
27
|
+
<%= form.submit rodauth.change_password_button, class: "btn btn-primary" %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
@@ -1,4 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<% content_for :title, rodauth.close_account_page_title %>
|
2
|
+
|
3
|
+
<%= form_with url: rodauth.close_account_path, method: :post, data: { turbo: false } do |form| %>
|
4
|
+
<% if rodauth.close_account_requires_password? %>
|
5
|
+
<div class="form-group mb-3">
|
6
|
+
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
7
|
+
<%= form.password_field rodauth.password_param, value: "", id: "password", autocomplete: rodauth.password_field_autocomplete_value, required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_param)}", aria: ({ invalid: true, describedby: "password_error_message" } if rodauth.field_error(rodauth.password_param)) %>
|
8
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_param), class: "invalid-feedback", id: "password_error_message") if rodauth.field_error(rodauth.password_param) %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<div class="form-group mb-3">
|
13
|
+
<%= form.submit rodauth.close_account_button, class: "btn btn-danger" %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -1,4 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<% content_for :title, rodauth.confirm_password_page_title %>
|
2
|
+
|
3
|
+
<%= form_with url: rodauth.confirm_password_path, method: :post, data: { turbo: false } do |form| %>
|
4
|
+
<div class="form-group mb-3">
|
5
|
+
<%= form.label "password", rodauth.password_label, class: "form-label" %>
|
6
|
+
<%= form.password_field rodauth.password_param, value: "", id: "password", autocomplete: rodauth.password_field_autocomplete_value, required: true, class: "form-control #{"is-invalid" if rodauth.field_error(rodauth.password_param)}", aria: ({ invalid: true, describedby: "password_error_message" } if rodauth.field_error(rodauth.password_param)) %>
|
7
|
+
<%= content_tag(:span, rodauth.field_error(rodauth.password_param), class: "invalid-feedback", id: "password_error_message") if rodauth.field_error(rodauth.password_param) %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group mb-3">
|
11
|
+
<%= form.submit rodauth.confirm_password_button, class: "btn btn-primary" %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|