lib/janus/manager.rb in janus-0.8.1 vs lib/janus/manager.rb in janus-0.9.0

- old
+ new

@@ -58,16 +58,16 @@ # Manually sets a user without going throught the whole login or # authenticate process. def set_user(user, options = {}) scope = options[:scope] || Janus.scope_for(user) - janus_sessions[scope.to_sym] = { :user_class => user.class, :user_id => user.id } + janus_sessions[scope.to_s] = { 'user_class' => user.class.name, 'user_id' => user.id } end # Manually removes the user without going throught the whole logout process. def unset_user(scope) - janus_sessions.delete(scope.to_sym) + janus_sessions.delete(scope.to_s) @users.delete(scope.to_sym) unless @users.nil? end # Returns the currently connected user. def user(scope) @@ -75,11 +75,11 @@ @users ||= {} if authenticated?(scope) if @users[scope].nil? begin - @users[scope] = session(scope)[:user_class].find(session(scope)[:user_id]) + @users[scope] = user_class(scope).find(session(scope)['user_id']) rescue ActiveRecord::RecordNotFound unset_user(scope) else Janus::Manager.run_callbacks(:fetch, @users[scope], self, :scope => scope) end @@ -89,14 +89,18 @@ end end # Returns the current session for user. def session(scope) - janus_sessions[scope.to_sym] + janus_sessions[scope.to_s] end private def janus_sessions request.session['janus'] ||= {} + end + + def user_class(scope) + session(scope)['user_class'].constantize end end end