module Proof::ProofActions::LocalInstanceMethods
Public Instance Methods
login()
click to toggle source
# File lib/proof/proof_actions.rb, line 25 def login proof_class = self.class.proof_options[:authenticatable].to_s.camelize.constantize identifier = self.class.proof_options[:identifier] user = proof_class.find_by(identifier => params[identifier]) if user && user.send(self.class.proof_options[:authenticate], params[self.class.proof_options[:password]]) auth_token = Proof::Token.from_data({ user_id: user.id }).to_s json = { auth_token: auth_token } if !self.class.proof_options[:block].nil? json = self.class.proof_options[:block].call(user, auth_token) end render json: json else render json: { error: "Invalid Credentials." }, status: :unauthorized end end