Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix error with redirect to admin if already logged

  • Loading branch information...
commit c4a4257af82b09d6d021175145373d01b112a1e0 1 parent 34b41d7
Cyril Mougel shingara authored
8 app/controllers/accounts_controller.rb
View
@@ -2,9 +2,11 @@ class AccountsController < ApplicationController
before_filter :verify_users, :only => [:login]
- def login
-
- redirect_back_or_default :controller => "admin/dashboard", :action => "index" if session[:user_id] == self.current_user.id
+ def login
+ if session[:user_id] && session[:user_id] == self.current_user.id
+ redirect_back_or_default :controller => "admin/dashboard", :action => "index"
+ return
+ end
@page_title = "#{this_blog.blog_name} - #{_('login')}"
case request.method
12 spec/controllers/accounts_controller_spec.rb
View
@@ -7,6 +7,7 @@
@user = mock_model(User, :new_record? => false, :reload => @user)
@user.stub!(:profile).and_return(Profile.find_by_label('admin'))
User.stub!(:authenticate).and_return(@user)
+ User.stub!(:find_by_id).with(@user.id).and_return(@user)
User.stub!(:count).and_return(1)
controller.stub!(:this_blog).and_return(Blog.default)
end
@@ -31,6 +32,17 @@ def make_request
make_request
response.should redirect_to('/bogus/location')
end
+
+ it 'redirects to /admin if no return' do
+ make_request
+ response.should redirect_to(:controller => 'admin')
+ end
+
+ it 'redirects to /admin if no return and your are logged' do
+ session[:user_id] = session[:user] = @user.id
+ make_request
+ response.should redirect_to(:controller => 'admin')
+ end
it "should redirect to signup if no users" do
User.stub!(:count).and_return(0)
Please sign in to comment.
Something went wrong with that request. Please try again.