Sha256: 8a1af3b81ac823393a5bf59e442e0fc9ef28b1eaed625d11dfc7141e2556a95f
Contents?: true
Size: 1.12 KB
Versions: 23
Compression:
Stored size: 1.12 KB
Contents
module Caboose class LoginController < Caboose::ApplicationController # GET /login def index @return_url = params[:return_url].nil? ? "/" : params[:return_url]; redirect_to @return_url if logged_in? end # POST /login def login @resp = StdClass.new('error' => '', 'redirect' => '') @return_url = params[:return_url].nil? ? "/" : params[:return_url] if (logged_in?) @resp.error = "Already logged in" else @username = params[:username] @password = params[:password] if (@username.nil? || @password.nil? || @password.strip.length == 0) @resp.error = "Invalid credentials" else @password = Digest::SHA1.hexdigest(Caboose::salt + @password) user = User.where(:username => @username, :password => @password).first if (user.nil?) @resp.error = "Invalid credentials" else login_user(user) @resp.redirect = @return_url end end end render json: @resp end end end
Version data entries
23 entries across 23 versions & 1 rubygems