Class: Authralia::Authenticate::Resource
- Defined in:
- lib/authenticate/resource.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource_class_name, auth_data) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(resource_class_name, auth_data) ⇒ Resource
Returns a new instance of Resource.
4 5 6 7 |
# File 'lib/authenticate/resource.rb', line 4 def initialize(resource_class_name, auth_data) @auth_data = auth_data @resource_class = resource_class_name.constantize end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/authenticate/resource.rb', line 9 def call if @auth_data.class.name == @resource_class.to_s response(status: SUCCESS, payload: @auth_data) else resource = @resource_class.protect_thcope(@auth_data) if resource&.authenticate(@auth_data[:password]) response(status: SUCCESS, payload: resource) else response( status: FAIL, message: "Incorrect Login Data" ) end end end |