Class: User

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
lib/generators/llm_meta_client/authentication/templates/app/models/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_omniauth(auth) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/llm_meta_client/authentication/templates/app/models/user.rb', line 10

def self.from_omniauth(auth)
  user = where(email: auth.info.email).first_or_initialize(
    google_id: auth.uid
  )

  token = auth.extra&.id_token
  if token.blank?
    user.errors.add(:id_token, "is missing from provider response")
    return user
  end

  user.id_token = token
  user.save
  user
end

Instance Method Details

#jwt_tokenObject

Return Google ID token (OpenID Connect) Validate expiration timestamp when using the token



28
29
30
# File 'lib/generators/llm_meta_client/authentication/templates/app/models/user.rb', line 28

def jwt_token
  id_token if id_token.present? && token_valid?
end