Sha256: 0d45d40fca6563deb6798fbb3d77e7916c2959194ae1a696347cbd5ebf3bbc86
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
class SessionsController < ApplicationController def create if authorized? && User.find(self.current_user.id).role.role_name == params[:role_name] @user = User.find(self.current_user.id) render :xml => @user.to_xml(:include => [:role, :account, :settings, :currencies], :except => [:activation_code,:crypted_password,:salt, :remember_token, :remember_token_expires_at]), :status=>:ok else logout_keeping_session! user = User.authenticate(params[:login], params[:password]) if user && user.role.role_name == params[:role_name] self.current_user = user new_cookie_flag = (params[:remember_me] == "1") handle_remember_cookie! new_cookie_flag flash[:notice] = "Logged in successfully" @user = User.find(self.current_user.id) render :xml => @user.to_xml(:include => [:role, :account, :settings, :currencies], :except => [:activation_code,:crypted_password,:salt, :remember_token, :remember_token_expires_at]), :status=>:ok else note_failed_signin @login = params[:login] @remember_me = params[:remember_me] @user = User.new render :xml => @user.to_xml(:only => [:id]), :status=>:ok end end end def destroy logout_killing_session! flash[:notice] = "You have been logged out." @user = User.new render :xml => @user.to_xml(:only => [:id]), :status=>:ok end protected def note_failed_signin flash[:error] = "Couldn't log you in as '#{params[:login]}'" logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}" end end
Version data entries
4 entries across 4 versions & 2 rubygems