module ErpTechSvcs class SessionController < ActionController::Base def create if login(params[:login],params[:password]) request.xhr? ? (render :json => {:success => true}) : (redirect_to params[:login_to]) else message = "Login failed. Try again" flash[:notice] = message request.xhr? ? (render :json => {:success => false, :errors => {:reason => message}}) : (render :text => message) end end def destroy logout login_url = params[:login_url].blank? ? ErpTechSvcs::Config.login_url : params[:login_url] redirect_to login_url, :notice => "You have successfully logged out." end end#SessionsController end#ErpTechSvcs