Class: Nyauth::SessionService
- Inherits:
-
Object
- Object
- Nyauth::SessionService
- Includes:
- ActiveModel::Model
- Defined in:
- app/services/nyauth/session_service.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(session_service_params = {}) ⇒ SessionService
constructor
A new instance of SessionService.
- #save(options = {}) ⇒ Object
Constructor Details
#initialize(session_service_params = {}) ⇒ SessionService
Returns a new instance of SessionService.
6 7 8 9 |
# File 'app/services/nyauth/session_service.rb', line 6 def initialize(session_service_params = {}) @email = session_service_params[:email] @password = session_service_params[:password] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/nyauth/session_service.rb', line 4 def client @client end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'app/services/nyauth/session_service.rb', line 4 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'app/services/nyauth/session_service.rb', line 4 def password @password end |
Instance Method Details
#save(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/services/nyauth/session_service.rb', line 11 def save( = {}) .reverse_merge!(as: :user) klass = [:as].to_s.classify.constantize @client = klass.authenticate(email, password) errors.add(:client, 'invalid email or password') unless @client client rescue errors.add(:client, 'invalid email or password') end |