Skip to content

Instantly share code, notes, and snippets.

@hayduke19us
Created January 22, 2015 00:30
Show Gist options
  • Select an option

  • Save hayduke19us/bda3ff1ba1adf0866750 to your computer and use it in GitHub Desktop.

Select an option

Save hayduke19us/bda3ff1ba1adf0866750 to your computer and use it in GitHub Desktop.
module ApiTools
extend ActiveSupport::Concern
class Authenticate < Base
attr_reader :password
def initialize args
super(args)
@password = args.fetch(:password, false)
end
def has_password?
if self.password
return true
else
self.error_response = ErrorSquad.no_password
return false
end
end
def valid_password?
if self.user.valid_password?(self.password)
return true
else
self.error_response = ErrorSquad.wrong_password
return false
end
end
def authentic_user
self.user ? self.valid_password? : false
end
def success?
if self.has_password? and self.authentic_user
self.success_response = SuccessSquad.sign_in
return true
else
return false
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment