rodauth-rails 1.5.4 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +6 -6
- data/lib/generators/rodauth/install_generator.rb +4 -2
- data/lib/generators/rodauth/migration/active_record/account_expiration.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/email_auth.erb +2 -2
- data/lib/generators/rodauth/migration/active_record/lockout.erb +4 -2
- data/lib/generators/rodauth/migration/active_record/otp.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/password_expiration.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/recovery_codes.erb +1 -1
- data/lib/generators/rodauth/migration/active_record/remember.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/reset_password.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/single_session.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/sms_codes.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/verify_account.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/verify_login_change.erb +2 -1
- data/lib/generators/rodauth/migration/active_record/webauthn.erb +2 -1
- data/lib/generators/rodauth/migration_generator.rb +35 -14
- data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +6 -6
- data/lib/generators/rodauth/templates/app/misc/rodauth_app.rb +2 -2
- data/lib/generators/rodauth/templates/app/misc/rodauth_main.rb +2 -0
- data/lib/generators/rodauth/views_generator.rb +18 -5
- data/lib/rodauth/rails/controller_methods.rb +1 -1
- data/lib/rodauth/rails/feature/base.rb +3 -1
- data/lib/rodauth/rails/feature/internal_request.rb +4 -2
- data/lib/rodauth/rails/feature.rb +2 -2
- data/lib/rodauth/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 879be6e1bbb5238e3f469002e1152d727948f970d2cda658b6ed0348a26f4b46
|
4
|
+
data.tar.gz: 79042f44b03bb8ab7f2225b79697b3399f79de272dc1c414de5ddc91b788b1cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb9d96c3e60c64a3f8367dd122f3eff3448f0c9a147510173a8d781483d7de6a88c264a717db14864e26a830a153c09bcbf6bad4865be97d3be248fcd0265d0
|
7
|
+
data.tar.gz: 422b0db632d1e0317d0f38c10d60405f2e53daf083919b460fcb29157e238ac0c2e6249660e09dc4a7f452718629d604c7a1211e073d32e4884a0b6ab4fea32a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 1.6.0 (2022-09-14)
|
2
|
+
|
3
|
+
* Avoid creating IDENTITY columns for primary foreign keys on SQL Server with Active Record (@janko)
|
4
|
+
|
5
|
+
* Make configuration name argument required in generated `RodauthMailer` (@janko)
|
6
|
+
|
7
|
+
* Make the Rails integration work without Action Mailer loaded (@janko)
|
8
|
+
|
9
|
+
* Don't redirect to login page when account is missing in `current_account` method (@janko)
|
10
|
+
|
11
|
+
## 1.5.5 (2022-08-04)
|
12
|
+
|
13
|
+
* Don't raise `ArgumentError` when calling `#current_account` without being logged in (@benkoshy)
|
14
|
+
|
15
|
+
* Abort `rodauth:views` generator when unknown feature was specified (@janko)
|
16
|
+
|
17
|
+
* Abort `rodauth:migration` generator when unknown feature was specified (@janko)
|
18
|
+
|
1
19
|
## 1.5.4 (2022-07-21)
|
2
20
|
|
3
21
|
* Generate account fixtures in `spec/fixtures` directory when using RSpec (@benkoshy)
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Provides Rails integration for the [Rodauth] authentication framework.
|
|
14
14
|
🎥 Screencasts:
|
15
15
|
|
16
16
|
* [Rails Authentication with Rodauth](https://www.youtube.com/watch?v=2hDpNikacf0)
|
17
|
-
* [Multifactor Authentication
|
17
|
+
* [Multifactor Authentication with Rodauth](https://www.youtube.com/watch?v=9ON-kgXpz2A&list=PLkGQXZLACDTGKsaRWstkHQdm2CUmT3SZ-) ([TOTP](https://youtu.be/9ON-kgXpz2A), [Recovery Codes](https://youtu.be/lkFCcE1Q5-w))
|
18
18
|
|
19
19
|
📚 Articles:
|
20
20
|
|
@@ -194,7 +194,7 @@ class RodauthApp < Rodauth::Rails::App
|
|
194
194
|
|
195
195
|
# require authentication for /dashboard/* and /account/* routes
|
196
196
|
if r.path.start_with?("/dashboard") || r.path.start_with?("/account")
|
197
|
-
rodauth.
|
197
|
+
rodauth.require_account # redirect to login page if not authenticated
|
198
198
|
end
|
199
199
|
end
|
200
200
|
end
|
@@ -208,7 +208,7 @@ class ApplicationController < ActionController::Base
|
|
208
208
|
private
|
209
209
|
|
210
210
|
def authenticate
|
211
|
-
rodauth.
|
211
|
+
rodauth.require_account # redirect to login page if not authenticated
|
212
212
|
end
|
213
213
|
end
|
214
214
|
```
|
@@ -727,7 +727,7 @@ For controller tests, you can log in accounts by modifying the session:
|
|
727
727
|
```rb
|
728
728
|
# app/controllers/articles_controller.rb
|
729
729
|
class ArticlesController < ApplicationController
|
730
|
-
before_action -> { rodauth.
|
730
|
+
before_action -> { rodauth.require_account }
|
731
731
|
|
732
732
|
def index
|
733
733
|
# ...
|
@@ -951,7 +951,7 @@ end
|
|
951
951
|
|
952
952
|
In addition to Zeitwerk compatibility, this extra layer catches Rodauth redirects
|
953
953
|
that happen on the controller level (e.g. when calling
|
954
|
-
`rodauth.
|
954
|
+
`rodauth.require_account` in a `before_action` filter).
|
955
955
|
|
956
956
|
### Roda app
|
957
957
|
|
@@ -1180,7 +1180,7 @@ License](https://opensource.org/licenses/MIT).
|
|
1180
1180
|
|
1181
1181
|
Everyone interacting in the rodauth-rails project's codebases, issue trackers,
|
1182
1182
|
chat rooms and mailing lists is expected to follow the [code of
|
1183
|
-
conduct](
|
1183
|
+
conduct](CODE_OF_CONDUCT.md).
|
1184
1184
|
|
1185
1185
|
[Rodauth]: https://github.com/jeremyevans/rodauth
|
1186
1186
|
[Sequel]: https://github.com/jeremyevans/sequel
|
@@ -63,6 +63,8 @@ module Rodauth
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def create_mailer
|
66
|
+
return unless defined?(ActionMailer)
|
67
|
+
|
66
68
|
template "app/mailers/rodauth_mailer.rb"
|
67
69
|
|
68
70
|
MAILER_VIEWS.each do |view|
|
@@ -88,8 +90,8 @@ module Rodauth
|
|
88
90
|
private
|
89
91
|
|
90
92
|
def migration_features
|
91
|
-
features = [
|
92
|
-
features <<
|
93
|
+
features = ["base", "reset_password", "verify_account", "verify_login_change"]
|
94
|
+
features << "remember" unless jwt?
|
93
95
|
features
|
94
96
|
end
|
95
97
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the account expiration feature
|
2
|
-
create_table :account_activity_times
|
2
|
+
create_table :account_activity_times, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.datetime :last_activity_at, null: false
|
5
6
|
t.datetime :last_login_at, null: false
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Used by the email auth feature
|
2
|
-
create_table :account_email_auth_keys
|
3
|
-
t
|
2
|
+
create_table :account_email_auth_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
4
4
|
t.string :key, null: false
|
5
5
|
t.datetime :deadline, null: false
|
6
6
|
t.datetime :email_last_sent, null: false, default: <%= current_timestamp %>
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# Used by the lockout feature
|
2
|
-
create_table :account_login_failures
|
2
|
+
create_table :account_login_failures, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.integer :number, null: false, default: 1
|
5
6
|
end
|
6
|
-
create_table :account_lockouts
|
7
|
+
create_table :account_lockouts, id: false do |t|
|
8
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
7
9
|
t.foreign_key :accounts, column: :id
|
8
10
|
t.string :key, null: false
|
9
11
|
t.datetime :deadline, null: false
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the otp feature
|
2
|
-
create_table :account_otp_keys
|
2
|
+
create_table :account_otp_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
t.integer :num_failures, null: false, default: 0
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the password expiration feature
|
2
|
-
create_table :account_password_change_times
|
2
|
+
create_table :account_password_change_times, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.datetime :changed_at, null: false, default: <%= current_timestamp %>
|
5
6
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the remember me feature
|
2
|
-
create_table :account_remember_keys
|
2
|
+
create_table :account_remember_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
t.datetime :deadline, null: false
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the password reset feature
|
2
|
-
create_table :account_password_reset_keys
|
2
|
+
create_table :account_password_reset_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
t.datetime :deadline, null: false
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the single session feature
|
2
|
-
create_table :account_session_keys
|
2
|
+
create_table :account_session_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the sms codes feature
|
2
|
-
create_table :account_sms_codes
|
2
|
+
create_table :account_sms_codes, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :phone_number, null: false
|
5
6
|
t.integer :num_failures
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the account verification feature
|
2
|
-
create_table :account_verification_keys
|
2
|
+
create_table :account_verification_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
t.datetime :requested_at, null: false, default: <%= current_timestamp %>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the verify login change feature
|
2
|
-
create_table :account_login_change_keys
|
2
|
+
create_table :account_login_change_keys, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :key, null: false
|
5
6
|
t.string :login, null: false
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Used by the webauthn feature
|
2
|
-
create_table :account_webauthn_user_ids
|
2
|
+
create_table :account_webauthn_user_ids, id: false do |t|
|
3
|
+
t.<%= primary_key_type(nil) %> :id, primary_key: true
|
3
4
|
t.foreign_key :accounts, column: :id
|
4
5
|
t.string :webauthn_id, null: false
|
5
6
|
end
|
@@ -17,7 +17,7 @@ module Rodauth
|
|
17
17
|
desc: "Name of the generated migration file"
|
18
18
|
|
19
19
|
def create_rodauth_migration
|
20
|
-
|
20
|
+
validate_features or return
|
21
21
|
|
22
22
|
migration_template "db/migrate/create_rodauth.rb", File.join(db_migrate_path, "#{migration_name}.rb")
|
23
23
|
end
|
@@ -30,7 +30,6 @@ module Rodauth
|
|
30
30
|
|
31
31
|
def migration_content
|
32
32
|
features
|
33
|
-
.select { |feature| File.exist?(migration_chunk(feature)) }
|
34
33
|
.map { |feature| File.read(migration_chunk(feature)) }
|
35
34
|
.map { |content| erb_eval(content) }
|
36
35
|
.join("\n")
|
@@ -45,19 +44,37 @@ module Rodauth
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
47
|
+
def migration_chunk(feature)
|
48
|
+
"#{MIGRATION_DIR}/#{feature}.erb"
|
49
|
+
end
|
50
|
+
|
51
|
+
def validate_features
|
52
|
+
if features.empty?
|
53
|
+
say "No features specified!", :yellow
|
54
|
+
false
|
55
|
+
elsif (features - valid_features).any?
|
56
|
+
say "No available migration for feature(s): #{(features - valid_features).join(", ")}", :red
|
57
|
+
false
|
58
|
+
else
|
59
|
+
true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def valid_features
|
64
|
+
Dir["#{MIGRATION_DIR}/*.erb"].map { |filename| File.basename(filename, ".erb") }
|
65
|
+
end
|
66
|
+
|
48
67
|
if defined?(::ActiveRecord::Railtie) # Active Record
|
49
68
|
include ::ActiveRecord::Generators::Migration
|
50
69
|
|
70
|
+
MIGRATION_DIR = "#{__dir__}/migration/active_record"
|
71
|
+
|
51
72
|
def db_migrate_path
|
52
73
|
return "db/migrate" unless ActiveRecord.version >= Gem::Version.new("5.0")
|
53
74
|
|
54
75
|
super
|
55
76
|
end
|
56
77
|
|
57
|
-
def migration_chunk(feature)
|
58
|
-
"#{__dir__}/migration/active_record/#{feature}.erb"
|
59
|
-
end
|
60
|
-
|
61
78
|
def migration_version
|
62
79
|
return unless ActiveRecord.version >= Gem::Version.new("5.0")
|
63
80
|
|
@@ -76,12 +93,18 @@ module Rodauth
|
|
76
93
|
generators = ::Rails.application.config.generators
|
77
94
|
column_type = generators.options[:active_record][:primary_key_type]
|
78
95
|
|
79
|
-
return unless column_type
|
80
|
-
|
81
96
|
if key
|
82
|
-
", #{key}: :#{column_type}"
|
97
|
+
", #{key}: :#{column_type}" if column_type
|
83
98
|
else
|
84
|
-
column_type
|
99
|
+
column_type || default_primary_key_type
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def default_primary_key_type
|
104
|
+
if ActiveRecord.version >= Gem::Version.new("5.1") && activerecord_adapter != "sqlite3"
|
105
|
+
:bigint
|
106
|
+
else
|
107
|
+
:integer
|
85
108
|
end
|
86
109
|
end
|
87
110
|
|
@@ -95,6 +118,8 @@ module Rodauth
|
|
95
118
|
else # Sequel
|
96
119
|
include ::Rails::Generators::Migration
|
97
120
|
|
121
|
+
MIGRATION_DIR = "#{__dir__}/migration/sequel"
|
122
|
+
|
98
123
|
def self.next_migration_number(dirname)
|
99
124
|
next_migration_number = current_migration_number(dirname) + 1
|
100
125
|
[Time.now.utc.strftime('%Y%m%d%H%M%S'), format('%.14d', next_migration_number)].max
|
@@ -104,10 +129,6 @@ module Rodauth
|
|
104
129
|
"db/migrate"
|
105
130
|
end
|
106
131
|
|
107
|
-
def migration_chunk(feature)
|
108
|
-
"#{__dir__}/migration/sequel/#{feature}.erb"
|
109
|
-
end
|
110
|
-
|
111
132
|
def db
|
112
133
|
db = ::Sequel::DATABASES.first if defined?(::Sequel)
|
113
134
|
db or fail Rodauth::Rails::Error, "missing Sequel database connection"
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class RodauthMailer < ApplicationMailer
|
2
|
-
def verify_account(name
|
2
|
+
def verify_account(name, account_id, key)
|
3
3
|
@email_link = email_link(name, :verify_account, account_id, key)
|
4
4
|
@account = find_account(name, account_id)
|
5
5
|
|
6
6
|
mail to: @account.email, subject: rodauth(name).verify_account_email_subject
|
7
7
|
end
|
8
8
|
|
9
|
-
def reset_password(name
|
9
|
+
def reset_password(name, account_id, key)
|
10
10
|
@email_link = email_link(name, :reset_password, account_id, key)
|
11
11
|
@account = find_account(name, account_id)
|
12
12
|
|
13
13
|
mail to: @account.email, subject: rodauth(name).reset_password_email_subject
|
14
14
|
end
|
15
15
|
|
16
|
-
def verify_login_change(name
|
16
|
+
def verify_login_change(name, account_id, key)
|
17
17
|
@email_link = email_link(name, :verify_login_change, account_id, key)
|
18
18
|
@account = find_account(name, account_id)
|
19
19
|
@new_email = @account.login_change_key.login
|
@@ -21,20 +21,20 @@ class RodauthMailer < ApplicationMailer
|
|
21
21
|
mail to: @new_email, subject: rodauth(name).verify_login_change_email_subject
|
22
22
|
end
|
23
23
|
|
24
|
-
def password_changed(name
|
24
|
+
def password_changed(name, account_id)
|
25
25
|
@account = find_account(name, account_id)
|
26
26
|
|
27
27
|
mail to: @account.email, subject: rodauth(name).password_changed_email_subject
|
28
28
|
end
|
29
29
|
|
30
|
-
# def email_auth(name
|
30
|
+
# def email_auth(name, account_id, key)
|
31
31
|
# @email_link = email_link(name, :email_auth, account_id, key)
|
32
32
|
# @account = find_account(name, account_id)
|
33
33
|
|
34
34
|
# mail to: @account.email, subject: rodauth(name).email_auth_email_subject
|
35
35
|
# end
|
36
36
|
|
37
|
-
# def unlock_account(name
|
37
|
+
# def unlock_account(name, account_id, key)
|
38
38
|
# @email_link = email_link(name, :unlock_account, account_id, key)
|
39
39
|
# @account = find_account(name, account_id)
|
40
40
|
|
@@ -13,12 +13,12 @@ class RodauthApp < Rodauth::Rails::App
|
|
13
13
|
r.rodauth # route rodauth requests
|
14
14
|
|
15
15
|
# ==> Authenticating requests
|
16
|
-
# Call `rodauth.
|
16
|
+
# Call `rodauth.require_account` for requests that you want to
|
17
17
|
# require authentication for. For example:
|
18
18
|
#
|
19
19
|
# # authenticate /dashboard/* and /account/* requests
|
20
20
|
# if r.path.start_with?("/dashboard") || r.path.start_with?("/account")
|
21
|
-
# rodauth.
|
21
|
+
# rodauth.require_account
|
22
22
|
# end
|
23
23
|
|
24
24
|
# ==> Secondary configurations
|
@@ -56,6 +56,7 @@ class RodauthMain < Rodauth::Rails::Auth
|
|
56
56
|
# Redirect to the app from login and registration pages if already logged in.
|
57
57
|
# already_logged_in { redirect login_redirect }
|
58
58
|
|
59
|
+
<% if defined?(ActionMailer) -%>
|
59
60
|
# ==> Emails
|
60
61
|
# Use a custom mailer for delivering authentication emails.
|
61
62
|
create_reset_password_email do
|
@@ -81,6 +82,7 @@ class RodauthMain < Rodauth::Rails::Auth
|
|
81
82
|
db.after_commit { email.deliver_later }
|
82
83
|
end
|
83
84
|
|
85
|
+
<% end -%>
|
84
86
|
# ==> Flash
|
85
87
|
<% unless json? || jwt? -%>
|
86
88
|
# Match flash keys with ones already used in the Rails app.
|
@@ -46,10 +46,7 @@ module Rodauth
|
|
46
46
|
}
|
47
47
|
|
48
48
|
def create_views
|
49
|
-
|
50
|
-
list |= VIEWS[feature] || []
|
51
|
-
list |= VIEWS[DEPENDENCIES[feature]] || []
|
52
|
-
end
|
49
|
+
validate_features or return
|
53
50
|
|
54
51
|
views.each do |view|
|
55
52
|
copy_file "app/views/rodauth/#{view}.html.erb", "app/views/#{directory}/#{view}.html.erb" do |content|
|
@@ -63,13 +60,29 @@ module Rodauth
|
|
63
60
|
|
64
61
|
private
|
65
62
|
|
63
|
+
def views
|
64
|
+
features.inject([]) do |list, feature|
|
65
|
+
list |= VIEWS.fetch(feature)
|
66
|
+
list |= VIEWS[DEPENDENCIES[feature]] || []
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def validate_features
|
71
|
+
if (features - VIEWS.keys).any?
|
72
|
+
say "No available view template for feature(s): #{(features - VIEWS.keys).join(", ")}", :error
|
73
|
+
false
|
74
|
+
else
|
75
|
+
true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
66
79
|
def features
|
67
80
|
if options[:all]
|
68
81
|
VIEWS.keys
|
69
82
|
elsif selected_features
|
70
83
|
selected_features.map(&:to_sym)
|
71
84
|
else
|
72
|
-
rodauth_configuration.features
|
85
|
+
rodauth_configuration.features & VIEWS.keys
|
73
86
|
end
|
74
87
|
end
|
75
88
|
|
@@ -3,13 +3,13 @@ module Rodauth
|
|
3
3
|
module Feature
|
4
4
|
module InternalRequest
|
5
5
|
def domain
|
6
|
-
return super unless missing_host?
|
6
|
+
return super unless missing_host? && rails_url_options
|
7
7
|
|
8
8
|
rails_url_options.fetch(:host)
|
9
9
|
end
|
10
10
|
|
11
11
|
def base_url
|
12
|
-
return super unless missing_host? && domain
|
12
|
+
return super unless missing_host? && domain && rails_url_options
|
13
13
|
|
14
14
|
scheme = rails_url_options[:protocol] || "http"
|
15
15
|
port = rails_url_options[:port]
|
@@ -43,6 +43,8 @@ module Rodauth
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def rails_url_options
|
46
|
+
return nil unless defined?(ActionMailer)
|
47
|
+
|
46
48
|
::Rails.application.config.action_mailer.default_url_options or
|
47
49
|
fail Error, "There is no information to set the URL host from. Please set config.action_mailer.default_url_options in your Rails application, or configure #domain and #base_url in your Rodauth configuration."
|
48
50
|
end
|
@@ -8,7 +8,7 @@ module Rodauth
|
|
8
8
|
require "rodauth/rails/feature/callbacks"
|
9
9
|
require "rodauth/rails/feature/csrf"
|
10
10
|
require "rodauth/rails/feature/render"
|
11
|
-
require "rodauth/rails/feature/email"
|
11
|
+
require "rodauth/rails/feature/email" if defined?(ActionMailer)
|
12
12
|
require "rodauth/rails/feature/instrumentation"
|
13
13
|
require "rodauth/rails/feature/internal_request"
|
14
14
|
|
@@ -16,7 +16,7 @@ module Rodauth
|
|
16
16
|
include Rodauth::Rails::Feature::Callbacks
|
17
17
|
include Rodauth::Rails::Feature::Csrf
|
18
18
|
include Rodauth::Rails::Feature::Render
|
19
|
-
include Rodauth::Rails::Feature::Email
|
19
|
+
include Rodauth::Rails::Feature::Email if defined?(ActionMailer)
|
20
20
|
include Rodauth::Rails::Feature::Instrumentation
|
21
21
|
include Rodauth::Rails::Feature::InternalRequest
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodauth-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|