Class: Devise::MultiAuth::CaptureSuccessfulExternalAuthentication
- Inherits:
-
Object
- Object
- Devise::MultiAuth::CaptureSuccessfulExternalAuthentication
- Defined in:
- app/services/devise/multi_auth/capture_successful_external_authentication.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user, auth) ⇒ CaptureSuccessfulExternalAuthentication
constructor
A new instance of CaptureSuccessfulExternalAuthentication.
Constructor Details
#initialize(user, auth) ⇒ CaptureSuccessfulExternalAuthentication
Returns a new instance of CaptureSuccessfulExternalAuthentication.
9 10 11 12 |
# File 'app/services/devise/multi_auth/capture_successful_external_authentication.rb', line 9 def initialize(user, auth) @user = user @auth = auth end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
8 9 10 |
# File 'app/services/devise/multi_auth/capture_successful_external_authentication.rb', line 8 def auth @auth end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'app/services/devise/multi_auth/capture_successful_external_authentication.rb', line 8 def user @user end |
Class Method Details
.call(user, auth = {}) ⇒ Object
3 4 5 6 |
# File 'app/services/devise/multi_auth/capture_successful_external_authentication.rb', line 3 def self.call(user, auth = {}) return true unless auth.present? new(user, auth).call end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 |
# File 'app/services/devise/multi_auth/capture_successful_external_authentication.rb', line 14 def call object = Authentication.where(user: user).where(auth.slice(:provider, :uid)).first_or_initialize object.access_token = auth.fetch(:credentials)[:token] object.refresh_token = auth.fetch(:credentials)[:refresh_token] object.save! end |