Commit 88f4efc56a0642c0564693810cebc3061c206db4
1 parent
fd488954
Exists in
master
and in
29 other branches
admin_features: Add support for selecting where to redirect users after
signup. (ActionItem2998) Signed-off-by: Daniel Bucher <daniel.bucher88@gmail.com> Signed-off-by: Luiz Matos <luizff.matos@gmail.com>
Showing
3 changed files
with
121 additions
and
2 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -69,6 +69,8 @@ class AccountController < ApplicationController |
69 | 69 | session[:notice] = _("This environment doesn't allow user registration.") |
70 | 70 | end |
71 | 71 | |
72 | + store_location(request.referer) unless params[:return_to] or session[:return_to] | |
73 | + | |
72 | 74 | @block_bot = !!session[:may_be_a_bot] |
73 | 75 | @invitation_code = params[:invitation_code] |
74 | 76 | begin |
... | ... | @@ -98,7 +100,7 @@ class AccountController < ApplicationController |
98 | 100 | end |
99 | 101 | if @user.activated? |
100 | 102 | self.current_user = @user |
101 | - redirect_to '/' | |
103 | + go_to_signup_initial_page | |
102 | 104 | else |
103 | 105 | @register_pending = true |
104 | 106 | end |
... | ... | @@ -369,6 +371,7 @@ class AccountController < ApplicationController |
369 | 371 | |
370 | 372 | def go_to_initial_page |
371 | 373 | if params[:return_to] |
374 | + #I never get here | |
372 | 375 | redirect_to params[:return_to] |
373 | 376 | elsif environment.enabled?('allow_change_of_redirection_after_login') |
374 | 377 | case user.preferred_login_redirection |
... | ... | @@ -394,6 +397,23 @@ class AccountController < ApplicationController |
394 | 397 | end |
395 | 398 | end |
396 | 399 | |
400 | + def go_to_signup_initial_page | |
401 | + case @user.environment.redirection_after_signup | |
402 | + when 'keep_on_same_page' | |
403 | + redirect_back_or_default(user.admin_url) | |
404 | + when 'site_homepage' | |
405 | + redirect_to :controller => :home | |
406 | + when 'user_profile_page' | |
407 | + redirect_to user.public_profile_url | |
408 | + when 'user_homepage' | |
409 | + redirect_to user.url | |
410 | + when 'user_control_panel' | |
411 | + redirect_to user.admin_url | |
412 | + else | |
413 | + redirect_to user.url | |
414 | + end | |
415 | + end | |
416 | + | |
397 | 417 | def redirect_if_logged_in |
398 | 418 | if logged_in? |
399 | 419 | go_to_initial_page | ... | ... |
features/signup.feature
... | ... | @@ -3,7 +3,7 @@ Feature: signup |
3 | 3 | I want to sign up to the site |
4 | 4 | So I can have fun using its features |
5 | 5 | |
6 | -@selenium | |
6 | + @selenium | |
7 | 7 | Scenario: successfull registration |
8 | 8 | Given I am on the homepage |
9 | 9 | When I follow "Login" |
... | ... | @@ -60,3 +60,84 @@ Feature: signup |
60 | 60 | And I fill in "Name" with "" |
61 | 61 | When I press "Save" |
62 | 62 | Then I should see "Name can't be blank" |
63 | + | |
64 | + @selenium | |
65 | + Scenario: user should stay on same page after signup | |
66 | + Given the environment is configured to stay on the same page after signup | |
67 | + And feature "skip_new_user_email_confirmation" is enabled on environment | |
68 | + And I am on /search/people | |
69 | + When I follow "Sign up" | |
70 | + And I fill in the following within ".no-boxes": | |
71 | + | e-Mail | josesilva@example.com | | |
72 | + | Username | josesilva | | |
73 | + | Password | secret | | |
74 | + | Password confirmation | secret | | |
75 | + | Full name | José da Silva | | |
76 | + And wait for the captcha signup time | |
77 | + And I press "Create my account" | |
78 | + Then I should be on /search/people | |
79 | + | |
80 | + @selenium | |
81 | + Scenario: user should go to his homepage after signup | |
82 | + Given the environment is configured to redirect to profile homepage after signup | |
83 | + And feature "skip_new_user_email_confirmation" is enabled on environment | |
84 | + And I am on /search/people | |
85 | + When I follow "Sign up" | |
86 | + And I fill in the following within ".no-boxes": | |
87 | + | e-Mail | josesilva@example.com | | |
88 | + | Username | josesilva | | |
89 | + | Password | secret | | |
90 | + | Password confirmation | secret | | |
91 | + | Full name | José da Silva | | |
92 | + And wait for the captcha signup time | |
93 | + And I press "Create my account" | |
94 | + Then I should be on josesilva's profile | |
95 | + | |
96 | + @selenium | |
97 | + Scenario: user should go to his control panel after signup | |
98 | + Given the environment is configured to redirect to profile control panel after signup | |
99 | + And feature "skip_new_user_email_confirmation" is enabled on environment | |
100 | + And I am on /search/people | |
101 | + When I follow "Sign up" | |
102 | + And I fill in the following within ".no-boxes": | |
103 | + | e-Mail | josesilva@example.com | | |
104 | + | Username | josesilva | | |
105 | + | Password | secret | | |
106 | + | Password confirmation | secret | | |
107 | + | Full name | José da Silva | | |
108 | + And wait for the captcha signup time | |
109 | + And I press "Create my account" | |
110 | + Then I should be on josesilva's control panel | |
111 | + | |
112 | + @selenium | |
113 | + Scenario: user should go to his profile page after signup | |
114 | + Given the environment is configured to redirect to profile page after signup | |
115 | + And feature "skip_new_user_email_confirmation" is enabled on environment | |
116 | + And I am on /search/people | |
117 | + When I follow "Sign up" | |
118 | + And I fill in the following within ".no-boxes": | |
119 | + | e-Mail | josesilva@example.com | | |
120 | + | Username | josesilva | | |
121 | + | Password | secret | | |
122 | + | Password confirmation | secret | | |
123 | + | Full name | José da Silva | | |
124 | + And wait for the captcha signup time | |
125 | + And I press "Create my account" | |
126 | + Then I should be on josesilva's profile | |
127 | + | |
128 | + @selenium | |
129 | + Scenario: user should go to the environment's homepage after signup | |
130 | + Given the environment is configured to redirect to site homepage after signup | |
131 | + And feature "skip_new_user_email_confirmation" is enabled on environment | |
132 | + And I am on /search/people | |
133 | + When I follow "Sign up" | |
134 | + And I fill in the following within ".no-boxes": | |
135 | + | e-Mail | josesilva@example.com | | |
136 | + | Username | josesilva | | |
137 | + | Password | secret | | |
138 | + | Password confirmation | secret | | |
139 | + | Full name | José da Silva | | |
140 | + And wait for the captcha signup time | |
141 | + And I press "Create my account" | |
142 | + Then I should be on the homepage | |
143 | + | ... | ... |
features/step_definitions/noosfero_steps.rb
... | ... | @@ -738,6 +738,24 @@ Given /^the profile (.*) is configured to (.*) after login$/ do |profile, option |
738 | 738 | profile.save |
739 | 739 | end |
740 | 740 | |
741 | +Given /^the environment is configured to (.*) after signup$/ do |option| | |
742 | + redirection = case option | |
743 | + when 'stay on the same page' | |
744 | + 'keep_on_same_page' | |
745 | + when 'redirect to site homepage' | |
746 | + 'site_homepage' | |
747 | + when 'redirect to user profile page' | |
748 | + 'user_profile_page' | |
749 | + when 'redirect to profile homepage' | |
750 | + 'user_homepage' | |
751 | + when 'redirect to profile control panel' | |
752 | + 'user_control_panel' | |
753 | + end | |
754 | + environment = Environment.default | |
755 | + environment.redirection_after_signup = redirection | |
756 | + environment.save | |
757 | +end | |
758 | + | |
741 | 759 | When /^wait for the captcha signup time$/ do |
742 | 760 | environment = Environment.default |
743 | 761 | sleep environment.min_signup_delay + 1 | ... | ... |