Commit b461081b2d206d5aecdaba4e52eeaed49ffe0e13
1 parent
88f4efc5
Exists in
staging
and in
42 other branches
admin_features: Add redirection options after signup when confirmation
email is enabled. (ActionItem2998) Signed-off-by: Daniel Bucher <daniel.bucher88@gmail.com> Signed-off-by: Luiz Matos <luizff.matos@gmail.com>
Showing
7 changed files
with
135 additions
and
9 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -79,6 +79,7 @@ class AccountController < ApplicationController |
79 | 79 | @user.environment = environment |
80 | 80 | @terms_of_use = environment.terms_of_use |
81 | 81 | @user.person_data = params[:profile_data] |
82 | + @user.return_to = session[:return_to] | |
82 | 83 | @person = Person.new(params[:profile_data]) |
83 | 84 | @person.environment = @user.environment |
84 | 85 | if request.post? |
... | ... | @@ -370,6 +371,12 @@ class AccountController < ApplicationController |
370 | 371 | end |
371 | 372 | |
372 | 373 | def go_to_initial_page |
374 | + if params[:redirection] | |
375 | + session[:return_to] = @user.return_to | |
376 | + @user.return_to = nil | |
377 | + @user.save | |
378 | + end | |
379 | + | |
373 | 380 | if params[:return_to] |
374 | 381 | #I never get here |
375 | 382 | redirect_to params[:return_to] | ... | ... |
app/models/user.rb
... | ... | @@ -71,7 +71,8 @@ class User < ActiveRecord::Base |
71 | 71 | body :recipient => user.name, |
72 | 72 | :activation_code => user.activation_code, |
73 | 73 | :environment => user.environment.name, |
74 | - :url => user.environment.top_url | |
74 | + :url => user.environment.top_url, | |
75 | + :return_to => user.return_to | |
75 | 76 | end |
76 | 77 | |
77 | 78 | def signup_welcome_email(user) |
... | ... | @@ -93,7 +94,7 @@ class User < ActiveRecord::Base |
93 | 94 | self.person.save! |
94 | 95 | end |
95 | 96 | end |
96 | - | |
97 | + | |
97 | 98 | has_one :person, :dependent => :destroy |
98 | 99 | belongs_to :environment |
99 | 100 | |
... | ... | @@ -183,7 +184,7 @@ class User < ActiveRecord::Base |
183 | 184 | encryption_methods[sym] = block |
184 | 185 | end |
185 | 186 | |
186 | - # the encryption method used for this instance | |
187 | + # the encryption method used for this instance | |
187 | 188 | def encryption_method |
188 | 189 | (password_type || User.system_encryption_method).to_sym |
189 | 190 | end |
... | ... | @@ -226,7 +227,7 @@ class User < ActiveRecord::Base |
226 | 227 | end |
227 | 228 | |
228 | 229 | def remember_token? |
229 | - remember_token_expires_at && Time.now.utc < remember_token_expires_at | |
230 | + remember_token_expires_at && Time.now.utc < remember_token_expires_at | |
230 | 231 | end |
231 | 232 | |
232 | 233 | # These create and unset the fields required for remembering users between browser closes |
... | ... | @@ -255,7 +256,7 @@ class User < ActiveRecord::Base |
255 | 256 | raise IncorrectPassword unless self.authenticated?(current) |
256 | 257 | self.force_change_password!(new, confirmation) |
257 | 258 | end |
258 | - | |
259 | + | |
259 | 260 | # Changes the password of a user without asking for the old password. This |
260 | 261 | # method is intended to be used by the "I forgot my password", and must be |
261 | 262 | # used with care. |
... | ... | @@ -326,7 +327,7 @@ class User < ActiveRecord::Base |
326 | 327 | end |
327 | 328 | |
328 | 329 | protected |
329 | - # before filter | |
330 | + # before filter | |
330 | 331 | def encrypt_password |
331 | 332 | return if password.blank? |
332 | 333 | self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? | ... | ... |
app/views/user/mailer/activation_code.rhtml
1 | 1 | <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> |
2 | 2 | |
3 | -<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code) }) %> | |
3 | +<%= word_wrap(_('Welcome to %{environment}! To activate your account, follow the link: %{activation_url}') % { :environment => @environment, :activation_url => @url + url_for(:controller => :account, :action => :activate, :activation_code => @activation_code, :redirection => (true if @return_to) ) }) %> | |
4 | 4 | |
5 | 5 | <%= _("Greetings,") %> |
6 | 6 | ... | ... |
db/schema.rb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | # |
10 | 10 | # It's strongly recommended to check this file into your version control system. |
11 | 11 | |
12 | -ActiveRecord::Schema.define(:version => 20140205191914) do | |
12 | +ActiveRecord::Schema.define(:version => 20140312184749) do | |
13 | 13 | |
14 | 14 | create_table "abuse_reports", :force => true do |t| |
15 | 15 | t.integer "reporter_id" |
... | ... | @@ -282,7 +282,7 @@ ActiveRecord::Schema.define(:version => 20140205191914) do |
282 | 282 | t.text "signup_welcome_text" |
283 | 283 | t.string "languages" |
284 | 284 | t.string "default_language" |
285 | - t.string "redirection_after_signup", :default => "keep_on_same_page" | |
285 | + t.string "redirection_after_signup", :default => "keep_on_same_page" | |
286 | 286 | end |
287 | 287 | |
288 | 288 | create_table "external_feeds", :force => true do |t| |
... | ... | @@ -620,6 +620,7 @@ ActiveRecord::Schema.define(:version => 20140205191914) do |
620 | 620 | t.datetime "chat_status_at" |
621 | 621 | t.string "activation_code", :limit => 40 |
622 | 622 | t.datetime "activated_at" |
623 | + t.string "return_to" | |
623 | 624 | end |
624 | 625 | |
625 | 626 | create_table "validation_infos", :force => true do |t| | ... | ... |
features/signup.feature
... | ... | @@ -141,3 +141,107 @@ Feature: signup |
141 | 141 | And I press "Create my account" |
142 | 142 | Then I should be on the homepage |
143 | 143 | |
144 | + @selenium | |
145 | + Scenario: user should stay on same page after following confirmation link | |
146 | + Given the environment is configured to stay on the same page after login | |
147 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
148 | + And feature "allow_change_of_redirection_after_login" is enabled on environment | |
149 | + And I am on /search/people | |
150 | + When I follow "Sign up" | |
151 | + And I fill in the following within ".no-boxes": | |
152 | + | e-Mail | josesilva@example.com | | |
153 | + | Username | josesilva | | |
154 | + | Password | secret | | |
155 | + | Password confirmation | secret | | |
156 | + | Full name | José da Silva | | |
157 | + And wait for the captcha signup time | |
158 | + And I press "Create my account" | |
159 | + And I go to josesilva's confirmation URL | |
160 | + And I fill in "Username" with "josesilva" | |
161 | + And I fill in "Password" with "secret" | |
162 | + And I press "Log in" | |
163 | + Then I should be on /search/people | |
164 | + | |
165 | + @selenium | |
166 | + Scenario: user should go to his homepage after following confirmation link | |
167 | + Given the environment is configured to redirect to profile homepage after login | |
168 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
169 | + And feature "allow_change_of_redirection_after_login" is enabled on environment | |
170 | + And I am on /search/people | |
171 | + When I follow "Sign up" | |
172 | + And I fill in the following within ".no-boxes": | |
173 | + | e-Mail | josesilva@example.com | | |
174 | + | Username | josesilva | | |
175 | + | Password | secret | | |
176 | + | Password confirmation | secret | | |
177 | + | Full name | José da Silva | | |
178 | + And wait for the captcha signup time | |
179 | + And I press "Create my account" | |
180 | + And I go to josesilva's confirmation URL | |
181 | + And I fill in "Username" with "josesilva" | |
182 | + And I fill in "Password" with "secret" | |
183 | + And I press "Log in" | |
184 | + Then I should be on /profile/josesilva | |
185 | + | |
186 | + @selenium | |
187 | + Scenario: user should go to his control panel after following confirmation link | |
188 | + Given the environment is configured to redirect to profile control panel after login | |
189 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
190 | + And feature "allow_change_of_redirection_after_login" is enabled on environment | |
191 | + And I am on /search/people | |
192 | + When I follow "Sign up" | |
193 | + And I fill in the following within ".no-boxes": | |
194 | + | e-Mail | josesilva@example.com | | |
195 | + | Username | josesilva | | |
196 | + | Password | secret | | |
197 | + | Password confirmation | secret | | |
198 | + | Full name | José da Silva | | |
199 | + And wait for the captcha signup time | |
200 | + And I press "Create my account" | |
201 | + And I go to josesilva's confirmation URL | |
202 | + And I fill in "Username" with "josesilva" | |
203 | + And I fill in "Password" with "secret" | |
204 | + And I press "Log in" | |
205 | + Then I should be on /myprofile/josesilva | |
206 | + | |
207 | + @selenium | |
208 | + Scenario: user should go to his profile page after following confirmation link | |
209 | + Given the environment is configured to redirect to profile page after login | |
210 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
211 | + And feature "allow_change_of_redirection_after_login" is enabled on environment | |
212 | + And I am on /search/people | |
213 | + When I follow "Sign up" | |
214 | + And I fill in the following within ".no-boxes": | |
215 | + | e-Mail | josesilva@example.com | | |
216 | + | Username | josesilva | | |
217 | + | Password | secret | | |
218 | + | Password confirmation | secret | | |
219 | + | Full name | José da Silva | | |
220 | + And wait for the captcha signup time | |
221 | + And I press "Create my account" | |
222 | + And I go to josesilva's confirmation URL | |
223 | + And I fill in "Username" with "josesilva" | |
224 | + And I fill in "Password" with "secret" | |
225 | + And I press "Log in" | |
226 | + Then I should be on /profile/josesilva | |
227 | + | |
228 | + @selenium | |
229 | + Scenario: user should go to the environment homepage after following confirmation link | |
230 | + Given the environment is configured to redirect to site homepage after login | |
231 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
232 | + And feature "allow_change_of_redirection_after_login" is enabled on environment | |
233 | + And I am on /search/people | |
234 | + When I follow "Sign up" | |
235 | + And I fill in the following within ".no-boxes": | |
236 | + | e-Mail | josesilva@example.com | | |
237 | + | Username | josesilva | | |
238 | + | Password | secret | | |
239 | + | Password confirmation | secret | | |
240 | + | Full name | José da Silva | | |
241 | + And wait for the captcha signup time | |
242 | + And I press "Create my account" | |
243 | + And I go to josesilva's confirmation URL | |
244 | + And I fill in "Username" with "josesilva" | |
245 | + And I fill in "Password" with "secret" | |
246 | + And I press "Log in" | |
247 | + Then I should be on the homepage | ... | ... |
features/support/paths.rb
... | ... | @@ -111,6 +111,10 @@ module NavigationHelpers |
111 | 111 | when /the user data path/ |
112 | 112 | '/account/user_data' |
113 | 113 | |
114 | + when /^(.+)'s confirmation URL/ | |
115 | + user = User[$1] | |
116 | + "/account/activate?activation_code=#{user.activation_code}&redirection=" + (user.return_to.nil? ? 'false' : 'true') | |
117 | + | |
114 | 118 | when /^(.+)'s members page/ |
115 | 119 | '/profile/%s/members' % profile_identifier($1) |
116 | 120 | ... | ... |