rodauth 0.10.0 → 1.0.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 +146 -0
- data/README.rdoc +644 -220
- data/Rakefile +99 -11
- data/doc/account_expiration.rdoc +55 -0
- data/doc/base.rdoc +104 -0
- data/doc/change_login.rdoc +29 -0
- data/doc/change_password.rdoc +26 -0
- data/doc/close_account.rdoc +31 -0
- data/doc/confirm_password.rdoc +22 -0
- data/doc/create_account.rdoc +34 -0
- data/doc/disallow_password_reuse.rdoc +37 -0
- data/doc/email_base.rdoc +19 -0
- data/doc/jwt.rdoc +35 -0
- data/doc/lockout.rdoc +83 -0
- data/doc/login.rdoc +27 -0
- data/doc/login_password_requirements_base.rdoc +50 -0
- data/doc/logout.rdoc +21 -0
- data/doc/otp.rdoc +100 -0
- data/doc/password_complexity.rdoc +50 -0
- data/doc/password_expiration.rdoc +52 -0
- data/doc/password_grace_period.rdoc +10 -0
- data/doc/recovery_codes.rdoc +60 -0
- data/doc/release_notes/1.0.0.txt +443 -0
- data/doc/remember.rdoc +82 -0
- data/doc/reset_password.rdoc +70 -0
- data/doc/session_expiration.rdoc +27 -0
- data/doc/single_session.rdoc +43 -0
- data/doc/sms_codes.rdoc +119 -0
- data/doc/two_factor_base.rdoc +27 -0
- data/doc/verify_account.rdoc +70 -0
- data/doc/verify_account_grace_period.rdoc +15 -0
- data/doc/verify_change_login.rdoc +9 -0
- data/lib/roda/plugins/rodauth.rb +3 -262
- data/lib/rodauth.rb +260 -0
- data/lib/rodauth/features/account_expiration.rb +108 -0
- data/lib/rodauth/features/base.rb +479 -0
- data/lib/rodauth/features/change_login.rb +77 -0
- data/lib/rodauth/features/change_password.rb +66 -0
- data/lib/rodauth/features/close_account.rb +82 -0
- data/lib/rodauth/features/confirm_password.rb +51 -0
- data/lib/rodauth/features/create_account.rb +128 -0
- data/lib/rodauth/features/disallow_password_reuse.rb +82 -0
- data/lib/rodauth/features/email_base.rb +63 -0
- data/lib/rodauth/features/jwt.rb +151 -0
- data/lib/rodauth/features/lockout.rb +262 -0
- data/lib/rodauth/features/login.rb +61 -0
- data/lib/rodauth/features/login_password_requirements_base.rb +123 -0
- data/lib/rodauth/features/logout.rb +37 -0
- data/lib/rodauth/features/otp.rb +338 -0
- data/lib/rodauth/features/password_complexity.rb +89 -0
- data/lib/rodauth/features/password_expiration.rb +111 -0
- data/lib/rodauth/features/password_grace_period.rb +46 -0
- data/lib/rodauth/features/recovery_codes.rb +240 -0
- data/lib/rodauth/features/remember.rb +200 -0
- data/lib/rodauth/features/reset_password.rb +207 -0
- data/lib/rodauth/features/session_expiration.rb +55 -0
- data/lib/rodauth/features/single_session.rb +87 -0
- data/lib/rodauth/features/sms_codes.rb +498 -0
- data/lib/rodauth/features/two_factor_base.rb +135 -0
- data/lib/rodauth/features/verify_account.rb +232 -0
- data/lib/rodauth/features/verify_account_grace_period.rb +76 -0
- data/lib/rodauth/features/verify_change_login.rb +20 -0
- data/lib/rodauth/migrations.rb +130 -0
- data/lib/rodauth/version.rb +9 -0
- data/spec/account_expiration_spec.rb +90 -0
- data/spec/all.rb +1 -0
- data/spec/change_login_spec.rb +149 -0
- data/spec/change_password_spec.rb +177 -0
- data/spec/close_account_spec.rb +162 -0
- data/spec/confirm_password_spec.rb +70 -0
- data/spec/create_account_spec.rb +127 -0
- data/spec/disallow_password_reuse_spec.rb +84 -0
- data/spec/lockout_spec.rb +228 -0
- data/spec/login_spec.rb +188 -0
- data/spec/migrate/001_tables.rb +103 -16
- data/spec/migrate/002_account_password_hash_column.rb +11 -0
- data/spec/migrate_password/001_tables.rb +60 -42
- data/spec/migrate_travis/001_tables.rb +116 -0
- data/spec/password_complexity_spec.rb +108 -0
- data/spec/password_expiration_spec.rb +243 -0
- data/spec/password_grace_period_spec.rb +93 -0
- data/spec/remember_spec.rb +424 -0
- data/spec/reset_password_spec.rb +185 -0
- data/spec/rodauth_spec.rb +57 -980
- data/spec/session_expiration_spec.rb +58 -0
- data/spec/single_session_spec.rb +107 -0
- data/spec/spec_helper.rb +202 -0
- data/spec/two_factor_spec.rb +1310 -0
- data/spec/verify_account_grace_period_spec.rb +135 -0
- data/spec/verify_account_spec.rb +142 -0
- data/spec/verify_change_login_spec.rb +46 -0
- data/spec/views/login.str +2 -2
- data/templates/add-recovery-codes.str +2 -0
- data/templates/button.str +5 -0
- data/templates/change-login.str +5 -18
- data/templates/change-password.str +6 -14
- data/templates/close-account.str +3 -6
- data/templates/confirm-password.str +4 -14
- data/templates/create-account.str +6 -30
- data/templates/login-confirm-field.str +6 -0
- data/templates/login-field.str +6 -0
- data/templates/login.str +5 -19
- data/templates/logout.str +2 -6
- data/templates/otp-auth-code-field.str +6 -0
- data/templates/otp-auth.str +8 -0
- data/templates/otp-disable.str +6 -0
- data/templates/otp-setup.str +21 -0
- data/templates/password-confirm-field.str +6 -0
- data/templates/password-field.str +6 -0
- data/templates/recovery-auth.str +12 -0
- data/templates/recovery-codes.str +6 -0
- data/templates/remember.str +8 -12
- data/templates/reset-password-request.str +2 -2
- data/templates/reset-password.str +4 -18
- data/templates/sms-auth.str +6 -0
- data/templates/sms-code-field.str +6 -0
- data/templates/sms-confirm.str +7 -0
- data/templates/sms-disable.str +7 -0
- data/templates/sms-request.str +5 -0
- data/templates/sms-setup.str +12 -0
- data/templates/unlock-account-request.str +3 -7
- data/templates/unlock-account.str +4 -7
- data/templates/verify-account-resend.str +2 -2
- data/templates/verify-account.str +2 -6
- metadata +191 -29
- data/lib/roda/plugins/rodauth/base.rb +0 -428
- data/lib/roda/plugins/rodauth/change_login.rb +0 -48
- data/lib/roda/plugins/rodauth/change_password.rb +0 -42
- data/lib/roda/plugins/rodauth/close_account.rb +0 -42
- data/lib/roda/plugins/rodauth/create_account.rb +0 -92
- data/lib/roda/plugins/rodauth/lockout.rb +0 -292
- data/lib/roda/plugins/rodauth/login.rb +0 -81
- data/lib/roda/plugins/rodauth/logout.rb +0 -36
- data/lib/roda/plugins/rodauth/remember.rb +0 -226
- data/lib/roda/plugins/rodauth/reset_password.rb +0 -205
- data/lib/roda/plugins/rodauth/verify_account.rb +0 -228
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
class Roda
|
|
2
|
-
module RodaPlugins
|
|
3
|
-
module Rodauth
|
|
4
|
-
VerifyAccount = Feature.define(:verify_account) do
|
|
5
|
-
depends :login, :create_account
|
|
6
|
-
route 'verify-account'
|
|
7
|
-
notice_flash "Your account has been verified"
|
|
8
|
-
view 'verify-account', 'Verify Account'
|
|
9
|
-
additional_form_tags
|
|
10
|
-
after
|
|
11
|
-
button 'Verify Account'
|
|
12
|
-
redirect
|
|
13
|
-
|
|
14
|
-
auth_value_methods(
|
|
15
|
-
:no_matching_verify_account_key_message,
|
|
16
|
-
:verify_account_autologin?,
|
|
17
|
-
:verify_account_email_subject,
|
|
18
|
-
:verify_account_email_sent_redirect,
|
|
19
|
-
:verify_account_email_sent_notice_flash,
|
|
20
|
-
:verify_account_id_column,
|
|
21
|
-
:verify_account_key_column,
|
|
22
|
-
:verify_account_key_param,
|
|
23
|
-
:verify_account_key_value,
|
|
24
|
-
:verify_account_table
|
|
25
|
-
)
|
|
26
|
-
auth_methods(
|
|
27
|
-
:account_from_verify_account_key,
|
|
28
|
-
:create_verify_account_key,
|
|
29
|
-
:create_verify_account_email,
|
|
30
|
-
:remove_verify_account_key,
|
|
31
|
-
:send_verify_account_email,
|
|
32
|
-
:verify_account,
|
|
33
|
-
:verify_account_email_body,
|
|
34
|
-
:verify_account_email_link,
|
|
35
|
-
:verify_account_key_insert_hash
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
get_block do |r, auth|
|
|
39
|
-
if key = r[auth.verify_account_key_param]
|
|
40
|
-
if auth._account_from_verify_account_key(key)
|
|
41
|
-
auth.verify_account_view
|
|
42
|
-
else
|
|
43
|
-
auth.set_redirect_error_flash auth.no_matching_verify_account_key_message
|
|
44
|
-
r.redirect auth.require_login_redirect
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
post_block do |r, auth|
|
|
50
|
-
if login = r[auth.login_param]
|
|
51
|
-
if auth._account_from_login(login.to_s) && !auth.open_account? && auth.verify_account_email_resend
|
|
52
|
-
auth.set_notice_flash auth.verify_account_email_sent_notice_flash
|
|
53
|
-
r.redirect auth.verify_account_email_sent_redirect
|
|
54
|
-
end
|
|
55
|
-
elsif key = r[auth.verify_account_key_param]
|
|
56
|
-
if auth._account_from_verify_account_key(key.to_s)
|
|
57
|
-
auth.transaction do
|
|
58
|
-
auth.verify_account
|
|
59
|
-
auth.remove_verify_account_key
|
|
60
|
-
auth.after_verify_account
|
|
61
|
-
end
|
|
62
|
-
if auth.verify_account_autologin?
|
|
63
|
-
auth.update_session
|
|
64
|
-
end
|
|
65
|
-
auth.set_notice_flash auth.verify_account_notice_flash
|
|
66
|
-
r.redirect(auth.verify_account_redirect)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def before_login_attempt
|
|
72
|
-
unless open_account?
|
|
73
|
-
set_error_flash attempt_to_login_to_unverified_account_notice_message
|
|
74
|
-
response.write resend_verify_account_view
|
|
75
|
-
request.halt
|
|
76
|
-
end
|
|
77
|
-
super
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def generate_verify_account_key_value
|
|
81
|
-
@verify_account_key_value = random_key
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def create_verify_account_key
|
|
85
|
-
ds = db[verify_account_table].where(verify_account_id_column=>account_id_value)
|
|
86
|
-
transaction do
|
|
87
|
-
ds.insert(verify_account_key_insert_hash) if ds.empty?
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def verify_account_key_insert_hash
|
|
92
|
-
{verify_account_id_column=>account_id_value, verify_account_key_column=>verify_account_key_value}
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def remove_verify_account_key
|
|
96
|
-
db[verify_account_table].where(verify_account_id_column=>account_id_value).delete
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def verify_account
|
|
100
|
-
account.set(account_status_id=>account_open_status_value).save_changes(:raise_on_failure=>true)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def verify_account_resend_additional_form_tags
|
|
104
|
-
nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def verify_account_resend_button
|
|
108
|
-
'Send Verification Email Again'
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def verify_account_email_resend
|
|
112
|
-
if @verify_account_key_value = db[verify_account_table].where(verify_account_id_column=>account_id_value).get(verify_account_key_column)
|
|
113
|
-
send_verify_account_email
|
|
114
|
-
true
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def attempt_to_create_unverified_account_notice_message
|
|
119
|
-
"The account you tried to create is currently awaiting verification"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def attempt_to_login_to_unverified_account_notice_message
|
|
123
|
-
"The account you tried to login with is currently awaiting verification"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def resend_verify_account_view
|
|
127
|
-
view('verify-account-resend', 'Resend Verification Email')
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def verify_account_email_sent_notice_flash
|
|
131
|
-
"An email has been sent to you with a link to verify your account"
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def create_account_notice_flash
|
|
135
|
-
verify_account_email_sent_notice_flash
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def after_create_account
|
|
139
|
-
generate_verify_account_key_value
|
|
140
|
-
create_verify_account_key
|
|
141
|
-
send_verify_account_email
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def new_account(login)
|
|
145
|
-
if _account_from_login(login)
|
|
146
|
-
set_error_flash attempt_to_create_unverified_account_notice_message
|
|
147
|
-
response.write resend_verify_account_view
|
|
148
|
-
request.halt
|
|
149
|
-
end
|
|
150
|
-
super
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def no_matching_verify_account_key_message
|
|
154
|
-
"invalid verify account key"
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def _account_from_verify_account_key(key)
|
|
158
|
-
@account = account_from_verify_account_key(key)
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def account_from_verify_account_key(key)
|
|
162
|
-
id, key = key.split('_', 2)
|
|
163
|
-
id_column = verify_account_id_column
|
|
164
|
-
ds = db[verify_account_table].
|
|
165
|
-
select(id_column).
|
|
166
|
-
where(id_column=>id, verify_account_key_column=>key)
|
|
167
|
-
@account = account_model.where(account_status_id=>account_unverified_status_value, account_id=>ds).first
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def verify_account_email_sent_redirect
|
|
171
|
-
require_login_redirect
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def verify_account_table
|
|
175
|
-
:account_verification_keys
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def verify_account_id_column
|
|
179
|
-
:id
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
def verify_account_key_column
|
|
183
|
-
:key
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def account_initial_status_value
|
|
187
|
-
account_unverified_status_value
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
attr_reader :verify_account_key_value
|
|
191
|
-
|
|
192
|
-
def create_verify_account_email
|
|
193
|
-
create_email(verify_account_email_subject, verify_account_email_body)
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def send_verify_account_email
|
|
197
|
-
create_verify_account_email.deliver!
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def verify_account_email_body
|
|
201
|
-
render('verify-account-email')
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def verify_account_email_link
|
|
205
|
-
"#{request.base_url}#{prefix}/#{verify_account_route}?#{verify_account_key_param}=#{account_id_value}_#{verify_account_key_value}"
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def verify_account_email_subject
|
|
209
|
-
'Verify Account'
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def verify_account_key_param
|
|
213
|
-
'key'
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def verify_account_autologin?
|
|
217
|
-
false
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def after_close_account
|
|
221
|
-
super
|
|
222
|
-
db[verify_account_table].where(reset_password_id_column=>account_id_value).delete
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|