Commit d7737eac9215c8743869edf26e121df1705dab4b

Authored by Marcos Pereira
1 parent d49b2288
Exists in master and in 1 other branch mezuro_spb

Redirect user when not logged in

Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza@hotmail.com>
src/noosfero-spb/gov_user/controllers/gov_user_plugin_controller.rb
... ... @@ -5,6 +5,12 @@ class GovUserPluginController &lt; ApplicationController
5 5 :governmental_sphere, :governmental_power, :juridical_nature, :sisp
6 6 ]
7 7  
  8 + before_action :require_login, :only => [:create_institution, :create_institution_admin, :create_institution_view_variables]
  9 +
  10 + def require_login
  11 + redirect_to :controller => "/account", :action => "login" unless user.present?
  12 + end
  13 +
8 14 def hide_registration_incomplete_percentage
9 15 response = false
10 16  
... ...
src/noosfero-spb/gov_user/test/functional/gov_user_plugin_controller_test.rb
... ... @@ -268,8 +268,8 @@ class GovUserPluginControllerTest &lt; ActionController::TestCase
268 268  
269 269 post :create_institution_admin
270 270  
271   - assert_response 403
272   - assert_template :access_denied
  271 + assert_response 302
  272 + assert_redirected_to(controller: "/account", action: "login")
273 273 end
274 274  
275 275 should "regular user can not access action create_institution_admin" do
... ...