Class: UserAuthentication

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/user_authentication.rb

Overview

Used to store user oauth authentications

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#authentication_provider_idInteger

Returns the current value of authentication_provider_id

Returns:

  • (Integer)

    the current value of authentication_provider_id



13
14
15
# File 'app/models/user_authentication.rb', line 13

def authentication_provider_id
  @authentication_provider_id
end

#created_atDateTime

Returns the current value of created_at

Returns:

  • (DateTime)

    the current value of created_at



13
14
15
# File 'app/models/user_authentication.rb', line 13

def created_at
  @created_at
end

#idInteger

Returns the current value of id

Returns:

  • (Integer)

    the current value of id



13
14
15
# File 'app/models/user_authentication.rb', line 13

def id
  @id
end

#paramsString

Returns the current value of params

Returns:

  • (String)

    the current value of params



13
14
15
# File 'app/models/user_authentication.rb', line 13

def params
  @params
end

#provider_nameString

Returns the current value of provider_name

Returns:

  • (String)

    the current value of provider_name



13
14
15
# File 'app/models/user_authentication.rb', line 13

def provider_name
  @provider_name
end

#tokenString

Returns the current value of token

Returns:

  • (String)

    the current value of token



13
14
15
# File 'app/models/user_authentication.rb', line 13

def token
  @token
end

#token_expires_atDateTime

Returns the current value of token_expires_at

Returns:

  • (DateTime)

    the current value of token_expires_at



13
14
15
# File 'app/models/user_authentication.rb', line 13

def token_expires_at
  @token_expires_at
end

#uidString

Returns the current value of uid

Returns:

  • (String)

    the current value of uid



13
14
15
# File 'app/models/user_authentication.rb', line 13

def uid
  @uid
end

#updated_atDateTime

Returns the current value of updated_at

Returns:

  • (DateTime)

    the current value of updated_at



13
14
15
# File 'app/models/user_authentication.rb', line 13

def updated_at
  @updated_at
end

#user_idInteger

Returns the current value of user_id

Returns:

  • (Integer)

    the current value of user_id



13
14
15
# File 'app/models/user_authentication.rb', line 13

def user_id
  @user_id
end

Class Method Details

.create_from_omniauth(params, user, provider) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/user_authentication.rb', line 19

def self.create_from_omniauth(params, user, provider)
  params = HashWithIndifferentAccess.new(params)
  create(
    provider_name: provider.name.capitalize!,
    user: user,
    authentication_provider: provider,
    uid: params['uid'],
    token: params['credentials']['token'],
    token_expires_at: Time.at(params['credentials']['expires_at']).to_datetime,
    params: params,
  )
end