Class: NimbleAuth::OmniauthAuthenticationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/nimble_auth/omniauth_authentication_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oauth) ⇒ OmniauthAuthenticationService

Returns a new instance of OmniauthAuthenticationService.



8
9
10
11
# File 'app/services/nimble_auth/omniauth_authentication_service.rb', line 8

def initialize(oauth)
  @oauth = oauth
  @identity = resource_identity_klass.includes(:user).find_by(uid: oauth[:uid], provider: oauth[:provider])
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



6
7
8
# File 'app/services/nimble_auth/omniauth_authentication_service.rb', line 6

def identity
  @identity
end

#oauthObject (readonly)

Returns the value of attribute oauth.



6
7
8
# File 'app/services/nimble_auth/omniauth_authentication_service.rb', line 6

def oauth
  @oauth
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
# File 'app/services/nimble_auth/omniauth_authentication_service.rb', line 13

def call
  return  if identity.present?

  
rescue ActiveRecord::RecordInvalid => error
  respond_with(message: error.message, status: :error)
end