public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
cleaner logged_in? implementation by [Catfish]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2488 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Nov 22 07:53:26 -0800 2006
commit  1e21424dd8c10a3f3fccda6134bc3166463d5acd
tree    96e615c57ac24443cda7e3a17fc28c8d123a9773
parent  aaf4195c608fd882a25378aa809d9ca52c1675f3
...
1
2
3
4
 
5
6
 
 
7
8
 
9
10
 
11
12
13
...
1
2
3
 
4
5
 
6
7
8
 
9
10
11
12
13
14
15
0
@@ -1,13 +1,15 @@
0
 module AuthenticatedSystem
0
   protected
0
     def logged_in?
0
- (@current_user ||= session[:user] ? User.find_by_site(site, session[:user]) : :false).is_a?(User)
0
+ current_user != :false
0
     end
0
-
0
+
0
+ # Accesses the current user from the session.
0
     def current_user
0
- @current_user if logged_in?
0
+ @current_user ||= (session[:user] && User.find_by_site(site, session[:user])) || :false
0
     end
0
     
0
+ # Store the given user in the session.
0
     def current_user=(new_user)
0
       session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id
0
       @current_user = new_user
...
180
181
182
183
 
184
185
186
...
180
181
182
 
183
184
185
186
0
@@ -180,7 +180,7 @@ context "Account Controller Password Reset" do
0
   specify "should not activate invalid token" do
0
     old_token = users(:arthur).token
0
     get :activate, :id => users(:arthur).token
0
- assert_nil @controller.send(:current_user)
0
+ assert !@controller.send(:logged_in?)
0
     assert_equal old_token, users(:arthur).reload.token
0
     assert_redirected_to :action => 'login'
0
     assert flash[:error]

Comments

    No one has commented yet.