rodauth-rails 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +9 -102
  4. data/lib/generators/rodauth/install_generator.rb +9 -10
  5. data/lib/generators/rodauth/migration/{account_expiration.erb → active_record/account_expiration.erb} +0 -0
  6. data/lib/generators/rodauth/migration/{active_sessions.erb → active_record/active_sessions.erb} +0 -0
  7. data/lib/generators/rodauth/migration/{audit_logging.erb → active_record/audit_logging.erb} +0 -0
  8. data/lib/generators/rodauth/migration/{base.erb → active_record/base.erb} +0 -0
  9. data/lib/generators/rodauth/migration/{disallow_password_reuse.erb → active_record/disallow_password_reuse.erb} +1 -1
  10. data/lib/generators/rodauth/migration/{email_auth.erb → active_record/email_auth.erb} +0 -0
  11. data/lib/generators/rodauth/migration/{jwt_refresh.erb → active_record/jwt_refresh.erb} +0 -0
  12. data/lib/generators/rodauth/migration/{lockout.erb → active_record/lockout.erb} +0 -0
  13. data/lib/generators/rodauth/migration/{otp.erb → active_record/otp.erb} +0 -0
  14. data/lib/generators/rodauth/migration/{password_expiration.erb → active_record/password_expiration.erb} +0 -0
  15. data/lib/generators/rodauth/migration/{recovery_codes.erb → active_record/recovery_codes.erb} +0 -0
  16. data/lib/generators/rodauth/migration/{remember.erb → active_record/remember.erb} +0 -0
  17. data/lib/generators/rodauth/migration/{reset_password.erb → active_record/reset_password.erb} +0 -0
  18. data/lib/generators/rodauth/migration/{single_session.erb → active_record/single_session.erb} +0 -0
  19. data/lib/generators/rodauth/migration/{sms_codes.erb → active_record/sms_codes.erb} +0 -0
  20. data/lib/generators/rodauth/migration/{verify_account.erb → active_record/verify_account.erb} +0 -0
  21. data/lib/generators/rodauth/migration/{verify_login_change.erb → active_record/verify_login_change.erb} +0 -0
  22. data/lib/generators/rodauth/migration/{webauthn.erb → active_record/webauthn.erb} +0 -0
  23. data/lib/generators/rodauth/migration/sequel/account_expiration.erb +7 -0
  24. data/lib/generators/rodauth/migration/sequel/active_sessions.erb +8 -0
  25. data/lib/generators/rodauth/migration/sequel/audit_logging.erb +17 -0
  26. data/lib/generators/rodauth/migration/sequel/base.erb +25 -0
  27. data/lib/generators/rodauth/migration/sequel/disallow_password_reuse.erb +6 -0
  28. data/lib/generators/rodauth/migration/sequel/email_auth.erb +7 -0
  29. data/lib/generators/rodauth/migration/sequel/jwt_refresh.erb +8 -0
  30. data/lib/generators/rodauth/migration/sequel/lockout.erb +11 -0
  31. data/lib/generators/rodauth/migration/sequel/otp.erb +7 -0
  32. data/lib/generators/rodauth/migration/sequel/password_expiration.erb +5 -0
  33. data/lib/generators/rodauth/migration/sequel/recovery_codes.erb +6 -0
  34. data/lib/generators/rodauth/migration/sequel/remember.erb +6 -0
  35. data/lib/generators/rodauth/migration/sequel/reset_password.erb +7 -0
  36. data/lib/generators/rodauth/migration/sequel/single_session.erb +5 -0
  37. data/lib/generators/rodauth/migration/sequel/sms_codes.erb +8 -0
  38. data/lib/generators/rodauth/migration/sequel/verify_account.erb +7 -0
  39. data/lib/generators/rodauth/migration/sequel/verify_login_change.erb +7 -0
  40. data/lib/generators/rodauth/migration/sequel/webauthn.erb +13 -0
  41. data/lib/generators/rodauth/migration_generator.rb +89 -9
  42. data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +24 -0
  43. data/lib/generators/rodauth/templates/app/models/account.rb +7 -0
  44. data/lib/generators/rodauth/templates/db/migrate/create_rodauth.rb +8 -0
  45. data/lib/rodauth/rails/app.rb +19 -7
  46. data/lib/rodauth/rails/controller_methods.rb +9 -0
  47. data/lib/rodauth/rails/feature/base.rb +10 -0
  48. data/lib/rodauth/rails/feature/instrumentation.rb +8 -0
  49. data/lib/rodauth/rails/middleware.rb +9 -0
  50. data/lib/rodauth/rails/model.rb +2 -97
  51. data/lib/rodauth/rails/version.rb +1 -1
  52. data/lib/rodauth/rails.rb +2 -1
  53. data/rodauth-rails.gemspec +3 -1
  54. metadata +68 -26
  55. data/lib/generators/rodauth/migration_helpers.rb +0 -77
  56. data/lib/rodauth/rails/app/flash.rb +0 -45
  57. data/lib/rodauth/rails/app/middleware.rb +0 -36
  58. data/lib/rodauth/rails/model/associations.rb +0 -195
@@ -1,195 +0,0 @@
1
- module Rodauth
2
- module Rails
3
- class Model
4
- class Associations
5
- attr_reader :rodauth
6
-
7
- def self.call(rodauth)
8
- new(rodauth).call
9
- end
10
-
11
- def initialize(rodauth)
12
- @rodauth = rodauth
13
- end
14
-
15
- def call
16
- rodauth.features
17
- .select { |feature| respond_to?(feature, true) }
18
- .flat_map { |feature| send(feature) }
19
- end
20
-
21
- private
22
-
23
- def remember
24
- {
25
- name: :remember_key,
26
- type: :has_one,
27
- table: rodauth.remember_table,
28
- foreign_key: rodauth.remember_id_column,
29
- }
30
- end
31
-
32
- def verify_account
33
- {
34
- name: :verification_key,
35
- type: :has_one,
36
- table: rodauth.verify_account_table,
37
- foreign_key: rodauth.verify_account_id_column,
38
- }
39
- end
40
-
41
- def reset_password
42
- {
43
- name: :password_reset_key,
44
- type: :has_one,
45
- table: rodauth.reset_password_table,
46
- foreign_key: rodauth.reset_password_id_column,
47
- }
48
- end
49
-
50
- def verify_login_change
51
- {
52
- name: :login_change_key,
53
- type: :has_one,
54
- table: rodauth.verify_login_change_table,
55
- foreign_key: rodauth.verify_login_change_id_column,
56
- }
57
- end
58
-
59
- def lockout
60
- [
61
- {
62
- name: :lockout,
63
- type: :has_one,
64
- table: rodauth.account_lockouts_table,
65
- foreign_key: rodauth.account_lockouts_id_column,
66
- },
67
- {
68
- name: :login_failure,
69
- type: :has_one,
70
- table: rodauth.account_login_failures_table,
71
- foreign_key: rodauth.account_login_failures_id_column,
72
- }
73
- ]
74
- end
75
-
76
- def email_auth
77
- {
78
- name: :email_auth_key,
79
- type: :has_one,
80
- table: rodauth.email_auth_table,
81
- foreign_key: rodauth.email_auth_id_column,
82
- }
83
- end
84
-
85
- def account_expiration
86
- {
87
- name: :activity_time,
88
- type: :has_one,
89
- table: rodauth.account_activity_table,
90
- foreign_key: rodauth.account_activity_id_column,
91
- }
92
- end
93
-
94
- def active_sessions
95
- {
96
- name: :active_session_keys,
97
- type: :has_many,
98
- table: rodauth.active_sessions_table,
99
- foreign_key: rodauth.active_sessions_account_id_column,
100
- }
101
- end
102
-
103
- def audit_logging
104
- {
105
- name: :authentication_audit_logs,
106
- type: :has_many,
107
- table: rodauth.audit_logging_table,
108
- foreign_key: rodauth.audit_logging_account_id_column,
109
- dependent: nil,
110
- }
111
- end
112
-
113
- def disallow_password_reuse
114
- {
115
- name: :previous_password_hashes,
116
- type: :has_many,
117
- table: rodauth.previous_password_hash_table,
118
- foreign_key: rodauth.previous_password_account_id_column,
119
- }
120
- end
121
-
122
- def jwt_refresh
123
- {
124
- name: :jwt_refresh_keys,
125
- type: :has_many,
126
- table: rodauth.jwt_refresh_token_table,
127
- foreign_key: rodauth.jwt_refresh_token_account_id_column,
128
- }
129
- end
130
-
131
- def password_expiration
132
- {
133
- name: :password_change_time,
134
- type: :has_one,
135
- table: rodauth.password_expiration_table,
136
- foreign_key: rodauth.password_expiration_id_column,
137
- }
138
- end
139
-
140
- def single_session
141
- {
142
- name: :session_key,
143
- type: :has_one,
144
- table: rodauth.single_session_table,
145
- foreign_key: rodauth.single_session_id_column,
146
- }
147
- end
148
-
149
- def otp
150
- {
151
- name: :otp_key,
152
- type: :has_one,
153
- table: rodauth.otp_keys_table,
154
- foreign_key: rodauth.otp_keys_id_column,
155
- }
156
- end
157
-
158
- def sms_codes
159
- {
160
- name: :sms_code,
161
- type: :has_one,
162
- table: rodauth.sms_codes_table,
163
- foreign_key: rodauth.sms_id_column,
164
- }
165
- end
166
-
167
- def recovery_codes
168
- {
169
- name: :recovery_codes,
170
- type: :has_many,
171
- table: rodauth.recovery_codes_table,
172
- foreign_key: rodauth.recovery_codes_id_column,
173
- }
174
- end
175
-
176
- def webauthn
177
- [
178
- {
179
- name: :webauthn_user_id,
180
- type: :has_one,
181
- table: rodauth.webauthn_user_ids_table,
182
- foreign_key: rodauth.webauthn_user_ids_account_id_column,
183
- },
184
- {
185
- name: :webauthn_keys,
186
- type: :has_many,
187
- table: rodauth.webauthn_keys_table,
188
- foreign_key: rodauth.webauthn_keys_account_id_column,
189
- }
190
- ]
191
- end
192
- end
193
- end
194
- end
195
- end