clearance 0.9.1 → 0.10.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.
Potentially problematic release.
This version of clearance might be problematic. Click here for more details.
- data/CHANGELOG.md +20 -1
- data/README.md +20 -20
- data/VERSION +1 -1
- data/app/controllers/clearance/passwords_controller.rb +0 -1
- data/app/controllers/clearance/sessions_controller.rb +3 -16
- data/app/controllers/clearance/users_controller.rb +2 -2
- data/app/models/clearance_mailer.rb +0 -11
- data/app/views/passwords/edit.html.erb +1 -1
- data/app/views/passwords/new.html.erb +1 -1
- data/app/views/sessions/new.html.erb +1 -1
- data/app/views/users/new.html.erb +1 -1
- data/clearance.gemspec +2 -10
- data/config/routes.rb +0 -4
- data/lib/clearance/shoulda_macros.rb +1 -9
- data/lib/clearance/user.rb +2 -18
- data/lib/rails/generators/clearance_features_templates/features/password_reset.feature +6 -0
- data/lib/rails/generators/clearance_features_templates/features/sign_in.feature +2 -10
- data/lib/rails/generators/clearance_features_templates/features/sign_out.feature +1 -1
- data/lib/rails/generators/clearance_features_templates/features/sign_up.feature +1 -26
- data/lib/rails/generators/clearance_features_templates/features/step_definitions/clearance_steps.rb +7 -28
- data/lib/rails/generators/clearance_templates/factories.rb +1 -1
- data/lib/rails/generators/clearance_templates/migrations/create_users.rb +0 -1
- data/lib/rails/generators/clearance_templates/migrations/update_users.rb +1 -2
- data/test/controllers/sessions_controller_test.rb +7 -40
- data/test/controllers/users_controller_test.rb +2 -4
- data/test/models/clearance_mailer_test.rb +1 -27
- data/test/models/user_test.rb +10 -46
- data/test/rails_root/test/factories/clearance.rb +1 -1
- metadata +23 -23
- data/app/controllers/clearance/confirmations_controller.rb +0 -74
- data/app/views/clearance_mailer/confirmation.html.erb +0 -5
- data/spec/rails_root/db/schema.rb +0 -29
- data/spec/rails_root/features/password_reset.feature +0 -33
- data/spec/rails_root/features/sign_in.feature +0 -35
- data/spec/rails_root/features/sign_out.feature +0 -15
- data/spec/rails_root/features/sign_up.feature +0 -45
- data/spec/rails_root/features/step_definitions/clearance_steps.rb +0 -138
- data/test/controllers/confirmations_controller_test.rb +0 -107
@@ -9,5 +9,5 @@ Factory.define :user do |user|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Factory.define :email_confirmed_user, :parent => :user do |user|
|
12
|
-
user.
|
12
|
+
user.after_build { warn "[DEPRECATION] The :email_confirmed_user factory is deprecated, please use the :user factory instead." }
|
13
13
|
end
|
@@ -7,8 +7,7 @@ class ClearanceUpdateUsers<%= schema_version_constant %> < ActiveRecord::Migrati
|
|
7
7
|
[:encrypted_password, 't.string :encrypted_password, :limit => 128'],
|
8
8
|
[:salt, 't.string :salt, :limit => 128'],
|
9
9
|
[:confirmation_token, 't.string :confirmation_token, :limit => 128'],
|
10
|
-
[:remember_token, 't.string :remember_token, :limit => 128']
|
11
|
-
[:email_confirmed, 't.boolean :email_confirmed, :default => false, :null => false']
|
10
|
+
[:remember_token, 't.string :remember_token, :limit => 128']
|
12
11
|
].delete_if {|c| existing_columns.include?(c.first.to_s)}
|
13
12
|
-%>
|
14
13
|
change_table(:users) do |t|
|
@@ -13,26 +13,9 @@ class SessionsControllerTest < ActionController::TestCase
|
|
13
13
|
should_not set_the_flash
|
14
14
|
end
|
15
15
|
|
16
|
-
context "on POST to #create with unconfirmed credentials" do
|
17
|
-
setup do
|
18
|
-
@user = Factory(:user)
|
19
|
-
ActionMailer::Base.deliveries.clear
|
20
|
-
post :create, :session => {
|
21
|
-
:email => @user.email,
|
22
|
-
:password => @user.password }
|
23
|
-
end
|
24
|
-
|
25
|
-
should_deny_access(:flash => /User has not confirmed email. Confirmation email will be resent./i)
|
26
|
-
|
27
|
-
should "send the confirmation email" do
|
28
|
-
assert_not_nil email = ActionMailer::Base.deliveries[0]
|
29
|
-
assert_match /account confirmation/i, email.subject
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
16
|
context "on POST to #create with good credentials" do
|
34
17
|
setup do
|
35
|
-
@user = Factory(:
|
18
|
+
@user = Factory(:user)
|
36
19
|
@user.update_attribute(:remember_token, "old-token")
|
37
20
|
post :create, :session => {
|
38
21
|
:email => @user.email,
|
@@ -58,7 +41,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
58
41
|
|
59
42
|
setup do
|
60
43
|
Clearance.configuration.cookie_expiration = lambda { custom_duration }
|
61
|
-
@user = Factory(:
|
44
|
+
@user = Factory(:user)
|
62
45
|
@user.update_attribute(:remember_token, "old-token2")
|
63
46
|
post :create, :session => {
|
64
47
|
:email => @user.email,
|
@@ -77,7 +60,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
77
60
|
context "on POST to #create with good credentials - cookie expiration set to nil (session cookie)" do
|
78
61
|
setup do
|
79
62
|
Clearance.configuration.cookie_expiration = lambda { nil }
|
80
|
-
@user = Factory(:
|
63
|
+
@user = Factory(:user)
|
81
64
|
@user.update_attribute(:remember_token, "old-token3")
|
82
65
|
post :create, :session => {
|
83
66
|
:email => @user.email,
|
@@ -95,7 +78,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
95
78
|
|
96
79
|
context "on POST to #create with good credentials and a session return url" do
|
97
80
|
setup do
|
98
|
-
@user = Factory(:
|
81
|
+
@user = Factory(:user)
|
99
82
|
@return_url = '/url_in_the_session'
|
100
83
|
@request.session[:return_to] = @return_url
|
101
84
|
post :create, :session => {
|
@@ -108,7 +91,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
108
91
|
|
109
92
|
context "on POST to #create with good credentials and a request return url" do
|
110
93
|
setup do
|
111
|
-
@user = Factory(:
|
94
|
+
@user = Factory(:user)
|
112
95
|
@return_url = '/url_in_the_request'
|
113
96
|
post :create, :session => {
|
114
97
|
:email => @user.email,
|
@@ -121,7 +104,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
121
104
|
|
122
105
|
context "on POST to #create with good credentials and a session return url and request return url" do
|
123
106
|
setup do
|
124
|
-
@user = Factory(:
|
107
|
+
@user = Factory(:user)
|
125
108
|
@return_url = '/url_in_the_session'
|
126
109
|
@request.session[:return_to] = @return_url
|
127
110
|
post :create, :session => {
|
@@ -133,22 +116,6 @@ class SessionsControllerTest < ActionController::TestCase
|
|
133
116
|
should redirect_to("the return URL") { @return_url }
|
134
117
|
end
|
135
118
|
|
136
|
-
context "on POST to #create with bad credentials" do
|
137
|
-
setup do
|
138
|
-
post :create, :session => {
|
139
|
-
:email => 'bad.email@example.com',
|
140
|
-
:password => "bad value" }
|
141
|
-
end
|
142
|
-
|
143
|
-
should set_the_flash.to(/bad/i)
|
144
|
-
should respond_with(:unauthorized)
|
145
|
-
should render_template(:new)
|
146
|
-
|
147
|
-
should "not be signed in" do
|
148
|
-
assert_nil cookies[:remember_token]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
119
|
context "on DELETE to #destroy given a signed out user" do
|
153
120
|
setup do
|
154
121
|
sign_out
|
@@ -160,7 +127,7 @@ class SessionsControllerTest < ActionController::TestCase
|
|
160
127
|
|
161
128
|
context "on DELETE to #destroy with a cookie" do
|
162
129
|
setup do
|
163
|
-
@user = Factory(:
|
130
|
+
@user = Factory(:user)
|
164
131
|
@user.update_attribute(:remember_token, "old-token")
|
165
132
|
@request.cookies["remember_token"] = "old-token"
|
166
133
|
delete :destroy
|
@@ -41,16 +41,14 @@ class UsersControllerTest < ActionController::TestCase
|
|
41
41
|
assert_equal @old_user_count + 1, User.count
|
42
42
|
end
|
43
43
|
|
44
|
-
should
|
45
|
-
|
46
|
-
should set_the_flash.to(/confirm/i)
|
44
|
+
should set_the_flash.to(/signed up/i)
|
47
45
|
should_redirect_to_url_after_create
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
51
49
|
context "A signed-in user" do
|
52
50
|
setup do
|
53
|
-
@user = Factory(:
|
51
|
+
@user = Factory(:user)
|
54
52
|
sign_in_as @user
|
55
53
|
end
|
56
54
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ClearanceMailerTest < ActiveSupport::TestCase
|
4
|
-
|
5
4
|
context "A change password email" do
|
6
5
|
setup do
|
7
6
|
@user = Factory(:user)
|
7
|
+
@user.forgot_password!
|
8
8
|
@email = ClearanceMailer.change_password @user
|
9
9
|
end
|
10
10
|
|
@@ -26,30 +26,4 @@ class ClearanceMailerTest < ActiveSupport::TestCase
|
|
26
26
|
assert_match /Change your password/, @email.subject
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
context "A confirmation email" do
|
31
|
-
setup do
|
32
|
-
@user = Factory(:user)
|
33
|
-
@email = ClearanceMailer.confirmation @user
|
34
|
-
end
|
35
|
-
|
36
|
-
should "be from DO_NOT_REPLY" do
|
37
|
-
assert_match /#{@email.from[0]}/i, Clearance.configuration.mailer_sender
|
38
|
-
end
|
39
|
-
|
40
|
-
should "be sent to user" do
|
41
|
-
assert_match /#{@user.email}/i, @email.to.first
|
42
|
-
end
|
43
|
-
|
44
|
-
should "set its subject" do
|
45
|
-
assert_match /Account confirmation/, @email.subject
|
46
|
-
end
|
47
|
-
|
48
|
-
should "contain a link to confirm the user's account" do
|
49
|
-
host = ActionMailer::Base.default_url_options[:host]
|
50
|
-
regexp = %r{http://#{host}/users/#{@user.id}/confirmation/new\?token=#{@user.confirmation_token}}
|
51
|
-
assert_match regexp, @email.body
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
29
|
end
|
data/test/models/user_test.rb
CHANGED
@@ -12,7 +12,11 @@ class UserTest < ActiveSupport::TestCase
|
|
12
12
|
context "When signing up" do
|
13
13
|
should validate_presence_of(:email)
|
14
14
|
should validate_presence_of(:password)
|
15
|
+
should allow_value("foo@example.co.uk").for(:email)
|
15
16
|
should allow_value("foo@example.com").for(:email)
|
17
|
+
should_not allow_value("foo@").for(:email)
|
18
|
+
should_not allow_value("foo@example..com").for(:email)
|
19
|
+
should_not allow_value("foo@.example.com").for(:email)
|
16
20
|
should_not allow_value("foo").for(:email)
|
17
21
|
should_not allow_value("example.com").for(:email)
|
18
22
|
|
@@ -34,10 +38,6 @@ class UserTest < ActiveSupport::TestCase
|
|
34
38
|
assert_not_nil Factory(:user).salt
|
35
39
|
end
|
36
40
|
|
37
|
-
should "initialize confirmation token" do
|
38
|
-
assert_not_nil Factory(:user).confirmation_token
|
39
|
-
end
|
40
|
-
|
41
41
|
context "encrypt password" do
|
42
42
|
setup do
|
43
43
|
@salt = "salt"
|
@@ -59,17 +59,6 @@ class UserTest < ActiveSupport::TestCase
|
|
59
59
|
user = Factory(:user, :email => "John.Doe@example.com")
|
60
60
|
assert_equal "John.Doe@example.com", user.email
|
61
61
|
end
|
62
|
-
|
63
|
-
should have_sent_email.with_subject(/account confirmation/i)
|
64
|
-
end
|
65
|
-
|
66
|
-
context "When signing up with email already confirmed" do
|
67
|
-
setup do
|
68
|
-
ActionMailer::Base.deliveries.clear
|
69
|
-
Factory(:user, :email_confirmed => true)
|
70
|
-
end
|
71
|
-
|
72
|
-
should_not have_sent_email
|
73
62
|
end
|
74
63
|
|
75
64
|
context "When multiple users have signed up" do
|
@@ -77,30 +66,6 @@ class UserTest < ActiveSupport::TestCase
|
|
77
66
|
should validate_uniqueness_of(:email)
|
78
67
|
end
|
79
68
|
|
80
|
-
# confirming email
|
81
|
-
|
82
|
-
context "A user without email confirmation" do
|
83
|
-
setup do
|
84
|
-
@user = Factory(:user)
|
85
|
-
assert ! @user.email_confirmed?
|
86
|
-
end
|
87
|
-
|
88
|
-
context "after #confirm_email!" do
|
89
|
-
setup do
|
90
|
-
assert @user.confirm_email!
|
91
|
-
@user.reload
|
92
|
-
end
|
93
|
-
|
94
|
-
should "have confirmed their email" do
|
95
|
-
assert @user.email_confirmed?
|
96
|
-
end
|
97
|
-
|
98
|
-
should "reset confirmation token" do
|
99
|
-
assert_nil @user.confirmation_token
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
69
|
# authenticating
|
105
70
|
|
106
71
|
context "A user" do
|
@@ -124,7 +89,7 @@ class UserTest < ActiveSupport::TestCase
|
|
124
89
|
|
125
90
|
context "When resetting authentication with reset_remember_token!" do
|
126
91
|
setup do
|
127
|
-
@user = Factory(:
|
92
|
+
@user = Factory(:user)
|
128
93
|
@user.remember_token = "old-token"
|
129
94
|
@user.reset_remember_token!
|
130
95
|
end
|
@@ -138,7 +103,7 @@ class UserTest < ActiveSupport::TestCase
|
|
138
103
|
|
139
104
|
context "An email confirmed user" do
|
140
105
|
setup do
|
141
|
-
@user = Factory(:
|
106
|
+
@user = Factory(:user)
|
142
107
|
@old_encrypted_password = @user.encrypted_password
|
143
108
|
end
|
144
109
|
|
@@ -157,10 +122,10 @@ class UserTest < ActiveSupport::TestCase
|
|
157
122
|
should "not generate the same remember token for users with the same password at the same time" do
|
158
123
|
Time.stubs(:now => Time.now)
|
159
124
|
password = 'secret'
|
160
|
-
first_user = Factory(:
|
125
|
+
first_user = Factory(:user,
|
161
126
|
:password => password,
|
162
127
|
:password_confirmation => password)
|
163
|
-
second_user = Factory(:
|
128
|
+
second_user = Factory(:user,
|
164
129
|
:password => password,
|
165
130
|
:password_confirmation => password)
|
166
131
|
|
@@ -169,11 +134,10 @@ class UserTest < ActiveSupport::TestCase
|
|
169
134
|
|
170
135
|
# recovering forgotten password
|
171
136
|
|
172
|
-
context "An
|
137
|
+
context "An user" do
|
173
138
|
setup do
|
174
|
-
@user = Factory(:
|
139
|
+
@user = Factory(:user)
|
175
140
|
@old_encrypted_password = @user.encrypted_password
|
176
|
-
@user.confirm_email!
|
177
141
|
end
|
178
142
|
|
179
143
|
context "who requests password reminder" do
|
@@ -9,5 +9,5 @@ Factory.define :user do |user|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Factory.define :email_confirmed_user, :parent => :user do |user|
|
12
|
-
user.
|
12
|
+
user.after_build { warn "[DEPRECATION] The :email_confirmed_user factory is deprecated, please use the :user factory instead." }
|
13
13
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 55
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 10
|
9
|
+
- 0
|
10
|
+
version: 0.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Croak
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
requirement: &id002 !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
hash: 27
|
63
63
|
segments:
|
@@ -67,6 +67,22 @@ dependencies:
|
|
67
67
|
version: 1.3.0
|
68
68
|
type: :development
|
69
69
|
version_requirements: *id002
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: cucumber
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - "="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 55
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 10
|
82
|
+
- 0
|
83
|
+
version: 0.10.0
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id003
|
70
86
|
description: Rails authentication with email & password.
|
71
87
|
email: support@thoughtbot.com
|
72
88
|
executables: []
|
@@ -82,13 +98,11 @@ files:
|
|
82
98
|
- README.md
|
83
99
|
- Rakefile
|
84
100
|
- VERSION
|
85
|
-
- app/controllers/clearance/confirmations_controller.rb
|
86
101
|
- app/controllers/clearance/passwords_controller.rb
|
87
102
|
- app/controllers/clearance/sessions_controller.rb
|
88
103
|
- app/controllers/clearance/users_controller.rb
|
89
104
|
- app/models/clearance_mailer.rb
|
90
105
|
- app/views/clearance_mailer/change_password.html.erb
|
91
|
-
- app/views/clearance_mailer/confirmation.html.erb
|
92
106
|
- app/views/passwords/edit.html.erb
|
93
107
|
- app/views/passwords/new.html.erb
|
94
108
|
- app/views/sessions/new.html.erb
|
@@ -151,13 +165,7 @@ files:
|
|
151
165
|
- spec/rails_root/config/initializers/session_store.rb
|
152
166
|
- spec/rails_root/config/locales/en.yml
|
153
167
|
- spec/rails_root/config/routes.rb
|
154
|
-
- spec/rails_root/db/schema.rb
|
155
168
|
- spec/rails_root/doc/README_FOR_APP
|
156
|
-
- spec/rails_root/features/password_reset.feature
|
157
|
-
- spec/rails_root/features/sign_in.feature
|
158
|
-
- spec/rails_root/features/sign_out.feature
|
159
|
-
- spec/rails_root/features/sign_up.feature
|
160
|
-
- spec/rails_root/features/step_definitions/clearance_steps.rb
|
161
169
|
- spec/rails_root/features/step_definitions/web_steps.rb
|
162
170
|
- spec/rails_root/features/support/env.rb
|
163
171
|
- spec/rails_root/features/support/paths.rb
|
@@ -185,7 +193,6 @@ files:
|
|
185
193
|
- spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb
|
186
194
|
- spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_test.rb
|
187
195
|
- spec/rails_root/vendor/plugins/dynamic_form/test/test_helper.rb
|
188
|
-
- test/controllers/confirmations_controller_test.rb
|
189
196
|
- test/controllers/passwords_controller_test.rb
|
190
197
|
- test/controllers/sessions_controller_test.rb
|
191
198
|
- test/controllers/users_controller_test.rb
|
@@ -280,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
287
|
requirements: []
|
281
288
|
|
282
289
|
rubyforge_project:
|
283
|
-
rubygems_version: 1.
|
290
|
+
rubygems_version: 1.4.1
|
284
291
|
signing_key:
|
285
292
|
specification_version: 3
|
286
293
|
summary: Rails authentication with email & password.
|
@@ -311,13 +318,7 @@ test_files:
|
|
311
318
|
- spec/rails_root/config/initializers/session_store.rb
|
312
319
|
- spec/rails_root/config/locales/en.yml
|
313
320
|
- spec/rails_root/config/routes.rb
|
314
|
-
- spec/rails_root/db/schema.rb
|
315
321
|
- spec/rails_root/doc/README_FOR_APP
|
316
|
-
- spec/rails_root/features/password_reset.feature
|
317
|
-
- spec/rails_root/features/sign_in.feature
|
318
|
-
- spec/rails_root/features/sign_out.feature
|
319
|
-
- spec/rails_root/features/sign_up.feature
|
320
|
-
- spec/rails_root/features/step_definitions/clearance_steps.rb
|
321
322
|
- spec/rails_root/features/step_definitions/web_steps.rb
|
322
323
|
- spec/rails_root/features/support/env.rb
|
323
324
|
- spec/rails_root/features/support/paths.rb
|
@@ -345,7 +346,6 @@ test_files:
|
|
345
346
|
- spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb
|
346
347
|
- spec/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_test.rb
|
347
348
|
- spec/rails_root/vendor/plugins/dynamic_form/test/test_helper.rb
|
348
|
-
- test/controllers/confirmations_controller_test.rb
|
349
349
|
- test/controllers/passwords_controller_test.rb
|
350
350
|
- test/controllers/sessions_controller_test.rb
|
351
351
|
- test/controllers/users_controller_test.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class Clearance::ConfirmationsController < ApplicationController
|
2
|
-
unloadable
|
3
|
-
|
4
|
-
skip_before_filter :authenticate, :only => [:new, :create]
|
5
|
-
before_filter :redirect_signed_in_confirmed_user, :only => [:new, :create]
|
6
|
-
before_filter :redirect_signed_out_confirmed_user, :only => [:new, :create]
|
7
|
-
before_filter :forbid_missing_token, :only => [:new, :create]
|
8
|
-
before_filter :forbid_non_existent_user, :only => [:new, :create]
|
9
|
-
|
10
|
-
def new
|
11
|
-
create
|
12
|
-
end
|
13
|
-
|
14
|
-
def create
|
15
|
-
@user = ::User.find_by_id_and_confirmation_token(
|
16
|
-
params[:user_id], params[:token])
|
17
|
-
@user.confirm_email!
|
18
|
-
|
19
|
-
sign_in(@user)
|
20
|
-
flash_success_after_create
|
21
|
-
redirect_to(url_after_create)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def redirect_signed_in_confirmed_user
|
27
|
-
user = ::User.find_by_id(params[:user_id])
|
28
|
-
if user && user.email_confirmed? && current_user == user
|
29
|
-
flash_success_after_create
|
30
|
-
redirect_to(url_after_create)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def redirect_signed_out_confirmed_user
|
35
|
-
user = ::User.find_by_id(params[:user_id])
|
36
|
-
if user && user.email_confirmed? && signed_out?
|
37
|
-
flash_already_confirmed
|
38
|
-
redirect_to(url_already_confirmed)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def forbid_missing_token
|
43
|
-
if params[:token].blank?
|
44
|
-
raise ActionController::Forbidden, "missing token"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def forbid_non_existent_user
|
49
|
-
unless ::User.find_by_id_and_confirmation_token(
|
50
|
-
params[:user_id], params[:token])
|
51
|
-
raise ActionController::Forbidden, "non-existent user"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def flash_success_after_create
|
56
|
-
flash[:success] = translate(:confirmed_email,
|
57
|
-
:scope => [:clearance, :controllers, :confirmations],
|
58
|
-
:default => "Confirmed email and signed in.")
|
59
|
-
end
|
60
|
-
|
61
|
-
def flash_already_confirmed
|
62
|
-
flash[:success] = translate(:already_confirmed_email,
|
63
|
-
:scope => [:clearance, :controllers, :confirmations],
|
64
|
-
:default => "Already confirmed email. Please sign in.")
|
65
|
-
end
|
66
|
-
|
67
|
-
def url_after_create
|
68
|
-
'/'
|
69
|
-
end
|
70
|
-
|
71
|
-
def url_already_confirmed
|
72
|
-
sign_in_url
|
73
|
-
end
|
74
|
-
end
|