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

- old
+ new

@@ -31,11 +31,11 @@ def authenticated?(scope) # :nodoc: !!session(scope) end # Logs a user 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) @@ -44,17 +44,17 @@ # Logs a user out from the given scopes or from all scopes at once # if no scope is defined. If no scope is left after logout, then the # whole session will be resetted. def logout(*scopes) scopes = janus_sessions.keys if scopes.empty? - + scopes.each do |scope| _user = user(scope) unset_user(scope) Janus::Manager.run_callbacks(:logout, _user, self, :scope => scope) end - + request.reset_session if janus_sessions.empty? end # Manually sets a user without going throught the whole login or # authenticate process. @@ -71,21 +71,21 @@ # Returns the currently connected user. def user(scope) scope = scope.to_sym @users ||= {} - + if authenticated?(scope) if @users[scope].nil? begin @users[scope] = session(scope)[:user_class].find(session(scope)[:user_id]) rescue ActiveRecord::RecordNotFound unset_user(scope) else Janus::Manager.run_callbacks(:fetch, @users[scope], self, :scope => scope) end end - + @users[scope] end end # Returns the current session for user.