rodauth-rails 1.4.1 → 1.4.2

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: b4cdb91c64a071bc9cb7895a98e7c07ddc047f1c201b65d255523bda906644dd
4
- data.tar.gz: 3b318fc66015b00e437b77fe650c5cf8c2af9c843b3b4e1f4890237ae9df261b
3
+ metadata.gz: 9a42fbc8522feb0a7d18227ca1cb3d79448c6d5d824befb040699afdb69318ea
4
+ data.tar.gz: 4d60492cc1ea2acf8176ffb6a05c6f0aba7deda63d1541da42de7f558e55b6e6
5
5
  SHA512:
6
- metadata.gz: ddee77b54a991b2699ed5bc60fd5b1d07cc79fda56be237628f3cac400d848cbab42feaba49bfa27eb63c5fb9709fa64edea1a6b0b2c2b98123df4965d38455f
7
- data.tar.gz: 2b08a11971c028ac6a45110a2265030ed074bbb2d03a46fff58f6ba673476abdae975032d2589dd2121134998e935dcb1ddb4f72056eefd7caa562a34552cd54
6
+ metadata.gz: 8782debac4a0b3bea9bb1849ab0817966f62c3bcf0cf352c2cf83d68e0fc35bce83a321e8c49f96d027450b87d6c196afd1e451a6e79e53cd35328dd84893d8c
7
+ data.tar.gz: 24de3dec4d061a9421de53062d75959d67091aff43dc26bf7f7fd749664e2288a4a9c198f24fa4ce8890b0c88f38c294d85a565b09aae330c0bcf7674242f112
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.4.2 (2022-05-15)
2
+
3
+ * Stop passing email addresses in mailer arguments on verifying login change (@janko)
4
+
5
+ * Extract finding account into a method in the generated mailer (@janko)
6
+
7
+ * Make generated Action Mailer integration work with secondary Rodauth configurations (@janko)
8
+
9
+ * Include `Rodauth::Rails.model` in generated Sequel account model as well (@janko)
10
+
1
11
  ## 1.4.1 (2022-05-08)
2
12
 
3
13
  * Deprecate `Rodauth::Rails::Model` constant (@janko)
data/README.md CHANGED
@@ -489,7 +489,7 @@ into the account model, which defines a password attribute and associations for
489
489
  tables used by enabled authentication features.
490
490
 
491
491
  ```rb
492
- class Account < ApplicationRecord
492
+ class Account < ActiveRecord::Base # Sequel::Model
493
493
  include Rodauth::Rails.model # or `Rodauth::Rails.model(:admin)`
494
494
  end
495
495
  ```
@@ -1,78 +1,64 @@
1
1
  class RodauthMailer < ApplicationMailer
2
- def verify_account(account_id, key)
3
- @email_link = rodauth.verify_account_url(key: email_token(account_id, key))
4
- <% if defined?(ActiveRecord::Railtie) -%>
5
- @account = Account.find(account_id)
6
- <% else -%>
7
- @account = Account.with_pk!(account_id)
8
- <% end -%>
2
+ def verify_account(name = nil, account_id, key)
3
+ @email_link = email_link(name, :verify_account, account_id, key)
4
+ @account = find_account(name, account_id)
9
5
 
10
- mail to: @account.email, subject: rodauth.verify_account_email_subject
6
+ mail to: @account.email, subject: rodauth(name).verify_account_email_subject
11
7
  end
12
8
 
13
- def reset_password(account_id, key)
14
- @email_link = rodauth.reset_password_url(key: email_token(account_id, key))
15
- <% if defined?(ActiveRecord::Railtie) -%>
16
- @account = Account.find(account_id)
17
- <% else -%>
18
- @account = Account.with_pk!(account_id)
19
- <% end -%>
9
+ def reset_password(name = nil, account_id, key)
10
+ @email_link = email_link(name, :reset_password, account_id, key)
11
+ @account = find_account(name, account_id)
20
12
 
21
- mail to: @account.email, subject: rodauth.reset_password_email_subject
13
+ mail to: @account.email, subject: rodauth(name).reset_password_email_subject
22
14
  end
23
15
 
24
- def verify_login_change(account_id, old_login, new_login, key)
25
- @old_login = old_login
26
- @new_login = new_login
27
- @email_link = rodauth.verify_login_change_url(key: email_token(account_id, key))
28
- <% if defined?(ActiveRecord::Railtie) -%>
29
- @account = Account.find(account_id)
30
- <% else -%>
31
- @account = Account.with_pk!(account_id)
32
- <% end -%>
16
+ def verify_login_change(name = nil, account_id, key)
17
+ @email_link = email_link(name, :verify_login_change, account_id, key)
18
+ @account = find_account(name, account_id)
19
+ @new_email = @account.login_change_key.login
33
20
 
34
- mail to: new_login, subject: rodauth.verify_login_change_email_subject
21
+ mail to: @new_email, subject: rodauth(name).verify_login_change_email_subject
35
22
  end
36
23
 
37
- def password_changed(account_id)
38
- <% if defined?(ActiveRecord::Railtie) -%>
39
- @account = Account.find(account_id)
40
- <% else -%>
41
- @account = Account.with_pk!(account_id)
42
- <% end -%>
24
+ def password_changed(name = nil, account_id)
25
+ @account = find_account(name, account_id)
43
26
 
44
- mail to: @account.email, subject: rodauth.password_changed_email_subject
27
+ mail to: @account.email, subject: rodauth(name).password_changed_email_subject
45
28
  end
46
29
 
47
- # def email_auth(account_id, key)
48
- # @email_link = rodauth.email_auth_url(key: email_token(account_id, key))
49
- <% if defined?(ActiveRecord::Railtie) -%>
50
- # @account = Account.find(account_id)
51
- <% else -%>
52
- # @account = Account.with_pk!(account_id)
53
- <% end -%>
30
+ # def email_auth(name = nil, account_id, key)
31
+ # @email_link = email_link(name, :email_auth, account_id, key)
32
+ # @account = find_account(name, account_id)
54
33
 
55
- # mail to: @account.email, subject: rodauth.email_auth_email_subject
34
+ # mail to: @account.email, subject: rodauth(name).email_auth_email_subject
56
35
  # end
57
36
 
58
- # def unlock_account(account_id, key)
59
- # @email_link = rodauth.unlock_account_url(key: email_token(account_id, key))
60
- <% if defined?(ActiveRecord::Railtie) -%>
61
- # @account = Account.find(account_id)
62
- <% else -%>
63
- # @account = Account.with_pk!(account_id)
64
- <% end -%>
37
+ # def unlock_account(name = nil, account_id, key)
38
+ # @email_link = email_link(name, :unlock_account, account_id, key)
39
+ # @account = find_account(name, account_id)
65
40
 
66
- # mail to: @account.email, subject: rodauth.unlock_account_email_subject
41
+ # mail to: @account.email, subject: rodauth(name).unlock_account_email_subject
67
42
  # end
68
43
 
69
44
  private
70
45
 
71
- def email_token(account_id, key)
72
- "#{account_id}_#{rodauth.compute_hmac(key)}"
46
+ def find_account(_name, account_id)
47
+ <% if defined?(ActiveRecord::Railtie) -%>
48
+ Account.find(account_id)
49
+ <% else -%>
50
+ Account.with_pk!(account_id)
51
+ <% end -%>
52
+ end
53
+
54
+ def email_link(name, action, account_id, key)
55
+ instance = rodauth(name)
56
+ instance.instance_variable_set(:@account, { id: account_id })
57
+ instance.instance_variable_set(:"@#{action}_key_value", key)
58
+ instance.public_send(:"#{action}_email_link")
73
59
  end
74
60
 
75
- def rodauth(name = nil)
61
+ def rodauth(name)
76
62
  RodauthApp.rodauth(name).allocate
77
63
  end
78
64
  end
@@ -56,22 +56,22 @@ class RodauthMain < Rodauth::Rails::Auth
56
56
  # ==> Emails
57
57
  # Use a custom mailer for delivering authentication emails.
58
58
  create_reset_password_email do
59
- RodauthMailer.reset_password(account_id, reset_password_key_value)
59
+ RodauthMailer.reset_password(*self.class.configuration_name, account_id, reset_password_key_value)
60
60
  end
61
61
  create_verify_account_email do
62
- RodauthMailer.verify_account(account_id, verify_account_key_value)
62
+ RodauthMailer.verify_account(*self.class.configuration_name, account_id, verify_account_key_value)
63
63
  end
64
64
  create_verify_login_change_email do |_login|
65
- RodauthMailer.verify_login_change(account_id, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_key_value)
65
+ RodauthMailer.verify_login_change(*self.class.configuration_name, account_id, verify_login_change_key_value)
66
66
  end
67
67
  create_password_changed_email do
68
- RodauthMailer.password_changed(account_id)
68
+ RodauthMailer.password_changed(*self.class.configuration_name, account_id)
69
69
  end
70
70
  # create_email_auth_email do
71
- # RodauthMailer.email_auth(account_id, email_auth_key_value)
71
+ # RodauthMailer.email_auth(*self.class.configuration_name, account_id, email_auth_key_value)
72
72
  # end
73
73
  # create_unlock_account_email do
74
- # RodauthMailer.unlock_account(account_id, unlock_account_key_value)
74
+ # RodauthMailer.unlock_account(*self.class.configuration_name, account_id, unlock_account_key_value)
75
75
  # end
76
76
  send_email do |email|
77
77
  # queue email delivery on the mailer after the transaction commits
@@ -9,6 +9,7 @@ class Account < ApplicationRecord
9
9
  end
10
10
  <% else -%>
11
11
  class Account < Sequel::Model
12
+ include Rodauth::Rails.model
12
13
  plugin :enum
13
14
  enum :status, unverified: 1, verified: 2, closed: 3
14
15
  end
@@ -1,8 +1,8 @@
1
1
  Someone with an account has requested their login be changed to this email address:
2
2
 
3
- Old email: <%= @old_login %>
3
+ Old email: <%= @account.email %>
4
4
 
5
- New email: <%= @new_login %>
5
+ New email: <%= @new_email %>
6
6
 
7
7
  If you did not request this login change, please ignore this message. If you
8
8
  requested this login change, please go to
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "1.4.1"
3
+ VERSION = "1.4.2"
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency "rodauth", "~> 2.23"
21
21
  spec.add_dependency "roda", "~> 3.55"
22
22
  spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
23
- spec.add_dependency "rodauth-model", "~> 0.1"
23
+ spec.add_dependency "rodauth-model", "~> 0.2"
24
24
  spec.add_dependency "tilt"
25
25
  spec.add_dependency "bcrypt"
26
26
 
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.1
4
+ version: 1.4.2
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-05-08 00:00:00.000000000 Z
11
+ date: 2022-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.1'
81
+ version: '0.2'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.1'
88
+ version: '0.2'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: tilt
91
91
  requirement: !ruby/object:Gem::Requirement