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.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +146 -0
  3. data/README.rdoc +644 -220
  4. data/Rakefile +99 -11
  5. data/doc/account_expiration.rdoc +55 -0
  6. data/doc/base.rdoc +104 -0
  7. data/doc/change_login.rdoc +29 -0
  8. data/doc/change_password.rdoc +26 -0
  9. data/doc/close_account.rdoc +31 -0
  10. data/doc/confirm_password.rdoc +22 -0
  11. data/doc/create_account.rdoc +34 -0
  12. data/doc/disallow_password_reuse.rdoc +37 -0
  13. data/doc/email_base.rdoc +19 -0
  14. data/doc/jwt.rdoc +35 -0
  15. data/doc/lockout.rdoc +83 -0
  16. data/doc/login.rdoc +27 -0
  17. data/doc/login_password_requirements_base.rdoc +50 -0
  18. data/doc/logout.rdoc +21 -0
  19. data/doc/otp.rdoc +100 -0
  20. data/doc/password_complexity.rdoc +50 -0
  21. data/doc/password_expiration.rdoc +52 -0
  22. data/doc/password_grace_period.rdoc +10 -0
  23. data/doc/recovery_codes.rdoc +60 -0
  24. data/doc/release_notes/1.0.0.txt +443 -0
  25. data/doc/remember.rdoc +82 -0
  26. data/doc/reset_password.rdoc +70 -0
  27. data/doc/session_expiration.rdoc +27 -0
  28. data/doc/single_session.rdoc +43 -0
  29. data/doc/sms_codes.rdoc +119 -0
  30. data/doc/two_factor_base.rdoc +27 -0
  31. data/doc/verify_account.rdoc +70 -0
  32. data/doc/verify_account_grace_period.rdoc +15 -0
  33. data/doc/verify_change_login.rdoc +9 -0
  34. data/lib/roda/plugins/rodauth.rb +3 -262
  35. data/lib/rodauth.rb +260 -0
  36. data/lib/rodauth/features/account_expiration.rb +108 -0
  37. data/lib/rodauth/features/base.rb +479 -0
  38. data/lib/rodauth/features/change_login.rb +77 -0
  39. data/lib/rodauth/features/change_password.rb +66 -0
  40. data/lib/rodauth/features/close_account.rb +82 -0
  41. data/lib/rodauth/features/confirm_password.rb +51 -0
  42. data/lib/rodauth/features/create_account.rb +128 -0
  43. data/lib/rodauth/features/disallow_password_reuse.rb +82 -0
  44. data/lib/rodauth/features/email_base.rb +63 -0
  45. data/lib/rodauth/features/jwt.rb +151 -0
  46. data/lib/rodauth/features/lockout.rb +262 -0
  47. data/lib/rodauth/features/login.rb +61 -0
  48. data/lib/rodauth/features/login_password_requirements_base.rb +123 -0
  49. data/lib/rodauth/features/logout.rb +37 -0
  50. data/lib/rodauth/features/otp.rb +338 -0
  51. data/lib/rodauth/features/password_complexity.rb +89 -0
  52. data/lib/rodauth/features/password_expiration.rb +111 -0
  53. data/lib/rodauth/features/password_grace_period.rb +46 -0
  54. data/lib/rodauth/features/recovery_codes.rb +240 -0
  55. data/lib/rodauth/features/remember.rb +200 -0
  56. data/lib/rodauth/features/reset_password.rb +207 -0
  57. data/lib/rodauth/features/session_expiration.rb +55 -0
  58. data/lib/rodauth/features/single_session.rb +87 -0
  59. data/lib/rodauth/features/sms_codes.rb +498 -0
  60. data/lib/rodauth/features/two_factor_base.rb +135 -0
  61. data/lib/rodauth/features/verify_account.rb +232 -0
  62. data/lib/rodauth/features/verify_account_grace_period.rb +76 -0
  63. data/lib/rodauth/features/verify_change_login.rb +20 -0
  64. data/lib/rodauth/migrations.rb +130 -0
  65. data/lib/rodauth/version.rb +9 -0
  66. data/spec/account_expiration_spec.rb +90 -0
  67. data/spec/all.rb +1 -0
  68. data/spec/change_login_spec.rb +149 -0
  69. data/spec/change_password_spec.rb +177 -0
  70. data/spec/close_account_spec.rb +162 -0
  71. data/spec/confirm_password_spec.rb +70 -0
  72. data/spec/create_account_spec.rb +127 -0
  73. data/spec/disallow_password_reuse_spec.rb +84 -0
  74. data/spec/lockout_spec.rb +228 -0
  75. data/spec/login_spec.rb +188 -0
  76. data/spec/migrate/001_tables.rb +103 -16
  77. data/spec/migrate/002_account_password_hash_column.rb +11 -0
  78. data/spec/migrate_password/001_tables.rb +60 -42
  79. data/spec/migrate_travis/001_tables.rb +116 -0
  80. data/spec/password_complexity_spec.rb +108 -0
  81. data/spec/password_expiration_spec.rb +243 -0
  82. data/spec/password_grace_period_spec.rb +93 -0
  83. data/spec/remember_spec.rb +424 -0
  84. data/spec/reset_password_spec.rb +185 -0
  85. data/spec/rodauth_spec.rb +57 -980
  86. data/spec/session_expiration_spec.rb +58 -0
  87. data/spec/single_session_spec.rb +107 -0
  88. data/spec/spec_helper.rb +202 -0
  89. data/spec/two_factor_spec.rb +1310 -0
  90. data/spec/verify_account_grace_period_spec.rb +135 -0
  91. data/spec/verify_account_spec.rb +142 -0
  92. data/spec/verify_change_login_spec.rb +46 -0
  93. data/spec/views/login.str +2 -2
  94. data/templates/add-recovery-codes.str +2 -0
  95. data/templates/button.str +5 -0
  96. data/templates/change-login.str +5 -18
  97. data/templates/change-password.str +6 -14
  98. data/templates/close-account.str +3 -6
  99. data/templates/confirm-password.str +4 -14
  100. data/templates/create-account.str +6 -30
  101. data/templates/login-confirm-field.str +6 -0
  102. data/templates/login-field.str +6 -0
  103. data/templates/login.str +5 -19
  104. data/templates/logout.str +2 -6
  105. data/templates/otp-auth-code-field.str +6 -0
  106. data/templates/otp-auth.str +8 -0
  107. data/templates/otp-disable.str +6 -0
  108. data/templates/otp-setup.str +21 -0
  109. data/templates/password-confirm-field.str +6 -0
  110. data/templates/password-field.str +6 -0
  111. data/templates/recovery-auth.str +12 -0
  112. data/templates/recovery-codes.str +6 -0
  113. data/templates/remember.str +8 -12
  114. data/templates/reset-password-request.str +2 -2
  115. data/templates/reset-password.str +4 -18
  116. data/templates/sms-auth.str +6 -0
  117. data/templates/sms-code-field.str +6 -0
  118. data/templates/sms-confirm.str +7 -0
  119. data/templates/sms-disable.str +7 -0
  120. data/templates/sms-request.str +5 -0
  121. data/templates/sms-setup.str +12 -0
  122. data/templates/unlock-account-request.str +3 -7
  123. data/templates/unlock-account.str +4 -7
  124. data/templates/verify-account-resend.str +2 -2
  125. data/templates/verify-account.str +2 -6
  126. metadata +191 -29
  127. data/lib/roda/plugins/rodauth/base.rb +0 -428
  128. data/lib/roda/plugins/rodauth/change_login.rb +0 -48
  129. data/lib/roda/plugins/rodauth/change_password.rb +0 -42
  130. data/lib/roda/plugins/rodauth/close_account.rb +0 -42
  131. data/lib/roda/plugins/rodauth/create_account.rb +0 -92
  132. data/lib/roda/plugins/rodauth/lockout.rb +0 -292
  133. data/lib/roda/plugins/rodauth/login.rb +0 -81
  134. data/lib/roda/plugins/rodauth/logout.rb +0 -36
  135. data/lib/roda/plugins/rodauth/remember.rb +0 -226
  136. data/lib/roda/plugins/rodauth/reset_password.rb +0 -205
  137. data/lib/roda/plugins/rodauth/verify_account.rb +0 -228
@@ -0,0 +1,135 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ describe 'Rodauth verify_account_grace_period feature' do
4
+ it "should support grace periods when verifying accounts" do
5
+ rodauth do
6
+ enable :login, :logout, :change_password, :create_account, :verify_account_grace_period
7
+ change_password_requires_password? false
8
+ end
9
+ roda do |r|
10
+ r.rodauth
11
+ r.root{view :content=>rodauth.logged_in? ? "Logged In#{rodauth.verified_account?}" : "Not Logged"}
12
+ end
13
+
14
+ visit '/create-account'
15
+ fill_in 'Login', :with=>'foo@example2.com'
16
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
17
+ fill_in 'Password', :with=>'0123456789'
18
+ fill_in 'Confirm Password', :with=>'0123456789'
19
+ click_button 'Create Account'
20
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
21
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
22
+ page.body.must_include('Logged Infalse')
23
+ page.current_path.must_equal '/'
24
+
25
+ logout
26
+ login(:login=>'foo@example2.com')
27
+ page.body.must_include('Logged Infalse')
28
+
29
+ visit '/change-password'
30
+ fill_in 'New Password', :with=>'012345678'
31
+ fill_in 'Confirm Password', :with=>'012345678'
32
+ click_button 'Change Password'
33
+ page.find('#notice_flash').text.must_equal "Your password has been changed"
34
+
35
+ DB[:account_verification_keys].update(:requested_at=>Time.now - 100000)
36
+
37
+ logout
38
+ login(:login=>'foo@example2.com', :pass=>'012345678')
39
+ page.find('#error_flash').text.must_equal 'The account you tried to login with is currently awaiting verification'
40
+ visit '/'
41
+ page.body.must_include('Not Logged')
42
+
43
+ visit link
44
+ click_button 'Verify Account'
45
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
46
+ page.body.must_include('Logged Intrue')
47
+ end
48
+
49
+ it "should not allow changing logins for unverified accounts" do
50
+ rodauth do
51
+ enable :login, :logout, :change_login, :verify_account_grace_period
52
+ change_login_requires_password? false
53
+ end
54
+ roda do |r|
55
+ r.rodauth
56
+ r.root{view :content=>rodauth.logged_in? ? "Logged In#{rodauth.verified_account?}" : "Not Logged"}
57
+ end
58
+
59
+ visit '/create-account'
60
+ fill_in 'Login', :with=>'foo@example2.com'
61
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
62
+ fill_in 'Password', :with=>'0123456789'
63
+ fill_in 'Confirm Password', :with=>'0123456789'
64
+ click_button 'Create Account'
65
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
66
+
67
+ visit '/change-login'
68
+ page.find('#error_flash').text.must_equal "Cannot change login for unverified account. Please verify this account before changing the login."
69
+ page.current_path.must_equal '/'
70
+
71
+ visit link
72
+ click_button 'Verify Account'
73
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
74
+ page.body.must_include('Logged Intrue')
75
+
76
+ visit '/change-login'
77
+ fill_in 'Login', :with=>'foo3@example.com'
78
+ fill_in 'Confirm Login', :with=>'foo3@example.com'
79
+ click_button 'Change Login'
80
+ page.find('#notice_flash').text.must_equal "Your login has been changed"
81
+ page.current_path.must_equal '/'
82
+ end
83
+
84
+ it "should allow verifying accounts while logged in during grace period" do
85
+ rodauth do
86
+ enable :login, :verify_account_grace_period
87
+ already_logged_in{request.redirect '/'}
88
+ end
89
+ roda do |r|
90
+ r.rodauth
91
+ r.root{view :content=>rodauth.logged_in? ? "Logged In#{rodauth.verified_account?}" : "Not Logged"}
92
+ end
93
+
94
+ visit '/create-account'
95
+ fill_in 'Login', :with=>'foo@example2.com'
96
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
97
+ fill_in 'Password', :with=>'0123456789'
98
+ fill_in 'Confirm Password', :with=>'0123456789'
99
+ click_button 'Create Account'
100
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
101
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
102
+ page.body.must_include('Logged Infalse')
103
+ page.current_path.must_equal '/'
104
+
105
+ visit link
106
+ click_button 'Verify Account'
107
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
108
+ page.body.must_include('Logged Intrue')
109
+ end
110
+
111
+ it "should remove verify keys if closing unverified accounts" do
112
+ rodauth do
113
+ enable :login, :close_account, :verify_account_grace_period
114
+ already_logged_in{request.redirect '/'}
115
+ close_account_requires_password? false
116
+ end
117
+ roda do |r|
118
+ r.rodauth
119
+ r.root{view :content=>rodauth.logged_in? ? "Logged In#{rodauth.verified_account?}" : "Not Logged"}
120
+ end
121
+
122
+ visit '/create-account'
123
+ fill_in 'Login', :with=>'foo@example2.com'
124
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
125
+ fill_in 'Password', :with=>'0123456789'
126
+ fill_in 'Confirm Password', :with=>'0123456789'
127
+ click_button 'Create Account'
128
+ email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
129
+
130
+ visit '/close-account'
131
+ click_button 'Close Account'
132
+ page.find('#notice_flash').text.must_equal "Your account has been closed"
133
+ DB[:account_verification_keys].must_be :empty?
134
+ end
135
+ end
@@ -0,0 +1,142 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ describe 'Rodauth verify_account feature' do
4
+ it "should support verifying accounts" do
5
+ rodauth do
6
+ enable :login, :create_account, :verify_account
7
+ verify_account_autologin? false
8
+ end
9
+ roda do |r|
10
+ r.rodauth
11
+ r.root{view :content=>""}
12
+ end
13
+
14
+ visit '/create-account'
15
+ fill_in 'Login', :with=>'foo@example2.com'
16
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
17
+ fill_in 'Password', :with=>'0123456789'
18
+ fill_in 'Confirm Password', :with=>'0123456789'
19
+ click_button 'Create Account'
20
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
21
+ page.current_path.must_equal '/'
22
+
23
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
24
+ login(:login=>'foo@example2.com')
25
+ page.find('#error_flash').text.must_equal 'The account you tried to login with is currently awaiting verification'
26
+ page.html.must_include("If you no longer have the email to verify the account, you can request that it be resent to you")
27
+ click_button 'Send Verification Email Again'
28
+ page.current_path.must_equal '/login'
29
+
30
+ email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com').must_equal link
31
+ visit '/create-account'
32
+ fill_in 'Login', :with=>'foo@example2.com'
33
+ click_button 'Create Account'
34
+ click_button 'Send Verification Email Again'
35
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
36
+ page.current_path.must_equal '/login'
37
+
38
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
39
+ visit link[0...-1]
40
+ page.find('#error_flash').text.must_equal "invalid verify account key"
41
+
42
+ visit link
43
+ click_button 'Verify Account'
44
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
45
+ page.current_path.must_equal '/'
46
+
47
+ login(:login=>'foo@example2.com')
48
+ page.find('#notice_flash').text.must_equal 'You have been logged in'
49
+ page.current_path.must_equal '/'
50
+ end
51
+
52
+ it "should support autologin when verifying accounts" do
53
+ rodauth do
54
+ enable :login, :create_account, :verify_account
55
+ end
56
+ roda do |r|
57
+ r.rodauth
58
+ r.root{view :content=>rodauth.logged_in? ? "Logged In" : "Not Logged"}
59
+ end
60
+
61
+ visit '/create-account'
62
+ fill_in 'Login', :with=>'foo@example2.com'
63
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
64
+ fill_in 'Password', :with=>'0123456789'
65
+ fill_in 'Confirm Password', :with=>'0123456789'
66
+ click_button 'Create Account'
67
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
68
+ page.current_path.must_equal '/'
69
+
70
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
71
+ visit link
72
+ click_button 'Verify Account'
73
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
74
+ page.body.must_include 'Logged In'
75
+ end
76
+
77
+ it "should handle uniqueness errors raised when inserting verify account token" do
78
+ rodauth do
79
+ enable :login, :verify_account
80
+ end
81
+ roda do |r|
82
+ def rodauth.raised_uniqueness_violation(*) super; true; end
83
+ r.rodauth
84
+ r.root{view :content=>rodauth.logged_in? ? "Logged In" : "Not Logged"}
85
+ end
86
+
87
+ visit '/create-account'
88
+ fill_in 'Login', :with=>'foo@example2.com'
89
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
90
+ fill_in 'Password', :with=>'0123456789'
91
+ fill_in 'Confirm Password', :with=>'0123456789'
92
+ click_button 'Create Account'
93
+ page.find('#notice_flash').text.must_equal "An email has been sent to you with a link to verify your account"
94
+ page.current_path.must_equal '/'
95
+
96
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
97
+ visit link
98
+ click_button 'Verify Account'
99
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
100
+ page.body.must_include 'Logged In'
101
+ end
102
+
103
+ it "should support verifying accounts via jwt" do
104
+ rodauth do
105
+ enable :login, :create_account, :verify_account
106
+ verify_account_autologin? false
107
+ verify_account_email_body{verify_account_email_link}
108
+ end
109
+ roda(:jwt) do |r|
110
+ r.rodauth
111
+ r.root{view :content=>""}
112
+ end
113
+
114
+ res = json_request('/create-account', :login=>'foo@example2.com', "login-confirm"=>'foo@example2.com', :password=>'0123456789', "password-confirm"=>'0123456789')
115
+ res.must_equal [200, {'success'=>"An email has been sent to you with a link to verify your account"}]
116
+ link = email_link(/key=.+$/, 'foo@example2.com')
117
+
118
+ res = json_request('/verify-account-resend', :login=>'foo@example.com')
119
+ res.must_equal [400, {'error'=>"Unable to resend verify account email"}]
120
+
121
+ res = json_request('/verify-account-resend', :login=>'foo@example3.com')
122
+ res.must_equal [400, {'error'=>"Unable to resend verify account email"}]
123
+
124
+ res = json_request('/login', :login=>'foo@example2.com',:password=>'0123456789')
125
+ res.must_equal [400, {'error'=>"The account you tried to login with is currently awaiting verification"}]
126
+
127
+ res = json_request('/verify-account-resend', :login=>'foo@example2.com')
128
+ res.must_equal [200, {'success'=>"An email has been sent to you with a link to verify your account"}]
129
+ email_link(/key=.+$/, 'foo@example2.com').must_equal link
130
+
131
+ res = json_request('/verify-account')
132
+ res.must_equal [400, {'error'=>"Unable to verify account"}]
133
+
134
+ res = json_request('/verify-account', :key=>link[4...-1])
135
+ res.must_equal [400, {"error"=>"Unable to verify account"}]
136
+
137
+ res = json_request('/verify-account', :key=>link[4..-1])
138
+ res.must_equal [200, {"success"=>"Your account has been verified"}]
139
+
140
+ json_login(:login=>'foo@example2.com')
141
+ end
142
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ describe 'Rodauth verify_change_login feature' do
4
+ it "should support reverifying accounts after changing logins" do
5
+ rodauth do
6
+ enable :login, :verify_change_login
7
+ change_login_requires_password? false
8
+ end
9
+ roda do |r|
10
+ r.rodauth
11
+ r.root{view :content=>rodauth.logged_in? ? "Logged In#{rodauth.verified_account?}" : "Not Logged"}
12
+ end
13
+
14
+ visit '/create-account'
15
+ fill_in 'Login', :with=>'foo@example2.com'
16
+ fill_in 'Confirm Login', :with=>'foo@example2.com'
17
+ fill_in 'Password', :with=>'0123456789'
18
+ fill_in 'Confirm Password', :with=>'0123456789'
19
+ click_button 'Create Account'
20
+ link = email_link(/(\/verify-account\?key=.+)$/, 'foo@example2.com')
21
+
22
+ visit '/change-login'
23
+ page.find('#error_flash').text.must_equal "Cannot change login for unverified account. Please verify this account before changing the login."
24
+ page.current_path.must_equal '/'
25
+
26
+ visit link
27
+ click_button 'Verify Account'
28
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
29
+ page.body.must_include('Logged Intrue')
30
+
31
+ visit '/change-login'
32
+ fill_in 'Login', :with=>'foo3@example.com'
33
+ fill_in 'Confirm Login', :with=>'foo3@example.com'
34
+ click_button 'Change Login'
35
+ page.find('#notice_flash').text.must_equal "Your login has been changed. An email has been sent to you with a link to verify your account"
36
+ page.current_path.must_equal '/'
37
+ page.body.must_include('Logged Infalse')
38
+ link2 = email_link(/(\/verify-account\?key=.+)$/, 'foo3@example.com')
39
+ link2.wont_equal link
40
+
41
+ visit link2
42
+ click_button 'Verify Account'
43
+ page.find('#notice_flash').text.must_equal "Your account has been verified"
44
+ page.body.must_include('Logged Intrue')
45
+ end
46
+ end
@@ -4,13 +4,13 @@
4
4
  <div class="form-group">
5
5
  <label class="col-sm-2 control-label" for="login">Login</label>
6
6
  <div class="col-sm-10">
7
- <input type="text" class="form-control#{' error' if @login_error}" name="l" id="login"/> #{@login_error}
7
+ <input type="text" class="form-control#{' error' if rodauth.field_error(rodauth.login_param)}" name="l" id="login"/> #{rodauth.field_error(rodauth.login_param)}
8
8
  </div>
9
9
  </div>
10
10
  <div class="form-group">
11
11
  <label class="col-sm-2 control-label" for="password">Password</label>
12
12
  <div class="col-sm-10">
13
- <input type="password" class="form-control#{' error' if @password_error}" name="p" id="password"/> #{@password_error}
13
+ <input type="password" class="form-control#{' error' if rodauth.field_error(rodauth.password_param)}" name="p" id="password"/> #{rodauth.field_error(rodauth.password_param)}
14
14
  </div>
15
15
  </div>
16
16
  <div class="form-group">
@@ -0,0 +1,2 @@
1
+ <pre id="recovery-codes">#{rodauth.recovery_codes.map{|s| h s}.join("\n\n")}</pre>
2
+ #{"<h2>Add Additional Recovery Codes</h2>#{rodauth.render('recovery-codes')}" if rodauth.can_add_recovery_codes?}
@@ -0,0 +1,5 @@
1
+ <div class="form-group">
2
+ <div class="col-sm-offset-2 col-sm-10">
3
+ <input type="submit" #{"name=\"#{h opts[:name]}\"" if opts[:name]} class="#{h(opts[:class] || 'btn btn-primary')}" value="#{h value}"/>
4
+ </div>
5
+ </div>
@@ -1,22 +1,9 @@
1
1
  <form method="post" class="rodauth form-horizontal" role="form" id="change-login-form">
2
2
  #{rodauth.change_login_additional_form_tags}
3
- #{csrf_tag if respond_to?(:csrf_tag)}
4
- <div class="form-group">
5
- <label class="col-sm-2 control-label" for="login">#{rodauth.login_label}</label>
6
- <div class="col-sm-10">
7
- <input type="text" class="form-control#{' error' if @login_error}" name="#{rodauth.login_param}" id="login" value="#{h request[rodauth.login_param]}"/> #{@login_error}
8
- </div>
9
- </div>
10
- <div class="form-group">
11
- <label class="col-sm-2 control-label" for="login-confirm">#{rodauth.login_confirm_label}</label>
12
- <div class="col-sm-10">
13
- <input type="text" class="form-control" name="#{rodauth.login_confirm_param}" id="login-confirm" value="#{h request[rodauth.login_confirm_param]}"/>
14
- </div>
15
- </div>
16
- <div class="form-group">
17
- <div class="col-sm-offset-2 col-sm-10">
18
- <input type="submit" class="btn btn-primary" value="#{rodauth.change_login_button}"/>
19
- </div>
20
- </div>
3
+ #{rodauth.csrf_tag}
4
+ #{rodauth.render('login-field')}
5
+ #{rodauth.render('login-confirm-field') if rodauth.require_login_confirmation?}
6
+ #{rodauth.render('password-field') if rodauth.change_login_requires_password?}
7
+ #{rodauth.button(rodauth.change_login_button)}
21
8
  </form>
22
9
 
@@ -1,21 +1,13 @@
1
1
  <form method="post" class="rodauth form-horizontal" role="form" id="change-password-form">
2
2
  #{rodauth.change_password_additional_form_tags}
3
- #{csrf_tag if respond_to?(:csrf_tag)}
3
+ #{rodauth.csrf_tag}
4
+ #{rodauth.render('password-field') if rodauth.change_password_requires_password?}
4
5
  <div class="form-group">
5
- <label class="col-sm-2 control-label" for="password">#{rodauth.password_label}</label>
6
+ <label class="col-sm-2 control-label" for="new-password">#{rodauth.new_password_label}</label>
6
7
  <div class="col-sm-10">
7
- <input type="password" class="form-control#{' error' if @password_error}" name="#{rodauth.password_param}" id="password"/> #{@password_error}
8
- </div>
9
- </div>
10
- <div class="form-group">
11
- <label class="col-sm-2 control-label" for="password-confirm">#{rodauth.password_confirm_label}</label>
12
- <div class="col-sm-10">
13
- <input type="password" class="form-control" name="#{rodauth.password_confirm_param}" id="password-confirm"/>
14
- </div>
15
- </div>
16
- <div class="form-group">
17
- <div class="col-sm-offset-2 col-sm-10">
18
- <input type="submit" class="btn btn-primary" value="#{rodauth.change_password_button}"/>
8
+ <input type="password" class="form-control#{' error' if rodauth.field_error(rodauth.new_password_param)}" name="#{rodauth.new_password_param}" id="new-password"/> #{rodauth.field_error(rodauth.new_password_param)}
19
9
  </div>
20
10
  </div>
11
+ #{rodauth.render('password-confirm-field') if rodauth.require_password_confirmation?}
12
+ #{rodauth.button(rodauth.change_password_button)}
21
13
  </form>
@@ -1,9 +1,6 @@
1
1
  <form method="post" class="rodauth form-horizontal" role="form" id="close-account-form">
2
2
  #{rodauth.close_account_additional_form_tags}
3
- #{csrf_tag if respond_to?(:csrf_tag)}
4
- <div class="form-group">
5
- <div class="col-sm-offset-2 col-sm-10">
6
- <input type="submit" class="btn btn-warning" value="#{rodauth.close_account_button}"/>
7
- </div>
8
- </div>
3
+ #{rodauth.csrf_tag}
4
+ #{rodauth.render('password-field') if rodauth.close_account_requires_password?}
5
+ #{rodauth.button(rodauth.close_account_button, :class=>'btn btn-warning')}
9
6
  </form>
@@ -1,16 +1,6 @@
1
1
  <form method="post" class="rodauth form-horizontal" role="form" id="confirm-password-form">
2
- #{rodauth.remember_confirm_additional_form_tags}
3
- #{csrf_tag if respond_to?(:csrf_tag)}
4
- <input type="hidden" name="confirm" value="t" />
5
- <div class="form-group">
6
- <label class="col-sm-2 control-label" for="password">#{rodauth.password_label}</label>
7
- <div class="col-sm-10">
8
- <input type="password" class="form-control#{' error' if @password_error}" name="#{rodauth.password_param}" id="password"/> #{@password_error}
9
- </div>
10
- </div>
11
- <div class="form-group">
12
- <div class="col-sm-offset-2 col-sm-10">
13
- <input type="submit" class="btn btn-primary" value="#{rodauth.remember_confirm_button}"/>
14
- </div>
15
- </div>
2
+ #{rodauth.confirm_password_additional_form_tags}
3
+ #{rodauth.csrf_tag}
4
+ #{rodauth.render('password-field')}
5
+ #{rodauth.button(rodauth.confirm_password_button)}
16
6
  </form>
@@ -1,33 +1,9 @@
1
1
  <form method="post" class="rodauth form-horizontal" role="form" id="create-account-form">
2
2
  #{rodauth.create_account_additional_form_tags}
3
- #{csrf_tag if respond_to?(:csrf_tag)}
4
- <div class="form-group">
5
- <label class="col-sm-2 control-label" for="login">#{rodauth.login_label}</label>
6
- <div class="col-sm-10">
7
- <input type="text" class="form-control#{' error' if @login_error}" name="#{rodauth.login_param}" id="login" value="#{h request[rodauth.login_param]}"/> #{@login_error}
8
- </div>
9
- </div>
10
- <div class="form-group">
11
- <label class="col-sm-2 control-label" for="login-confirm">#{rodauth.login_confirm_label}</label>
12
- <div class="col-sm-10">
13
- <input type="text" class="form-control" name="login-confirm" id="#{rodauth.login_confirm_param}" value="#{h request[rodauth.login_confirm_param]}"/>
14
- </div>
15
- </div>
16
- <div class="form-group">
17
- <label class="col-sm-2 control-label" for="password">#{rodauth.password_label}</label>
18
- <div class="col-sm-10">
19
- <input type="password" class="form-control#{' error' if @password_error}" name="#{rodauth.password_param}" id="password"/> #{@password_error}
20
- </div>
21
- </div>
22
- <div class="form-group">
23
- <label class="col-sm-2 control-label" for="password-confirm">#{rodauth.password_confirm_label}</label>
24
- <div class="col-sm-10">
25
- <input type="password" class="form-control" name="#{rodauth.password_confirm_param}" id="password-confirm"/>
26
- </div>
27
- </div>
28
- <div class="form-group">
29
- <div class="col-sm-offset-2 col-sm-10">
30
- <input type="submit" class="btn btn-primary" value="#{rodauth.create_account_button}"/>
31
- </div>
32
- </div>
3
+ #{rodauth.csrf_tag}
4
+ #{rodauth.render('login-field')}
5
+ #{rodauth.render('login-confirm-field') if rodauth.require_login_confirmation?}
6
+ #{rodauth.render('password-field')}
7
+ #{rodauth.render('password-confirm-field') if rodauth.require_password_confirmation?}
8
+ #{rodauth.button(rodauth.create_account_button)}
33
9
  </form>