Class: Nyauth::Session
- Inherits:
-
Object
- Object
- Nyauth::Session
- Includes:
- ActiveModel::Model
- Defined in:
- app/services/nyauth/session.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(service_params = {}) ⇒ Session
constructor
A new instance of Session.
- #save(options = {}) ⇒ Object
Constructor Details
#initialize(service_params = {}) ⇒ Session
Returns a new instance of Session.
6 7 8 9 |
# File 'app/services/nyauth/session.rb', line 6 def initialize(service_params = {}) @email = service_params[:email] @password = service_params[:password] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/nyauth/session.rb', line 4 def client @client end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'app/services/nyauth/session.rb', line 4 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'app/services/nyauth/session.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.rb', line 11 def save( = {}) .reverse_merge!(as: :user) klass = [:as].to_s.classify.constantize @client = klass.authenticate(email, password) errors.add(:base, :invalid_email_or_password) unless @client client rescue errors.add(:base, :invalid_email_or_password) end |