lib/ditty/helpers/authentication.rb in ditty-0.7.0.pre.rc1 vs lib/ditty/helpers/authentication.rb in ditty-0.7.0
- old
+ new
@@ -7,15 +7,16 @@
module Ditty
module Helpers
module Authentication
def current_user
return anonymous_user if current_user_id.nil?
- User[current_user_id]
+ @current_user ||= User[current_user_id]
end
def current_user=(user)
env['rack.session'] = {} if env['rack.session'].nil?
env['rack.session']['user_id'] = user.id if user
+ @current_user = user
end
def current_user_id
return env['rack.session']['user_id'] if env['rack.session']
env['omniauth.auth'].uid if env['omniauth.auth']