lib/janus/manager.rb in janus-0.5.0 vs lib/janus/manager.rb in janus-0.6.0

- old
+ new

@@ -32,11 +32,11 @@ !!session(scope) end # Logs a user in. # - # FIXME: what should happen when a user signs in but a user is already signed in?! + # FIXME: what should happen when a user signs in but a user is already signed in for the same scope?! def login(user, options = {}) options[:scope] ||= Janus.scope_for(user) set_user(user, options) Janus::Manager.run_callbacks(:login, user, self, options) end @@ -74,11 +74,16 @@ scope = scope.to_sym @users ||= {} if authenticated?(scope) if @users[scope].nil? + begin @users[scope] = session(scope)[:user_class].find(session(scope)[:user_id]) - Janus::Manager.run_callbacks(:fetch, @users[scope], self, :scope => scope) + rescue ActiveRecord::RecordNotFound + unset_user(scope) + else + Janus::Manager.run_callbacks(:fetch, @users[scope], self, :scope => scope) + end end @users[scope] end end