Class: SignIn::OAuthSession

Inherits:
ApplicationRecord show all
Defined in:
app/models/sign_in/o_auth_session.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/sign_in/o_auth_session.rb', line 18

def active?
  refresh_valid? && session_max_valid?
end

#confirm_client_idObject (private)



36
37
38
# File 'app/models/sign_in/o_auth_session.rb', line 36

def confirm_client_id
  errors.add(:base, 'Client id must map to a configuration') unless ClientConfig.valid_client_id?(client_id:)
end

#refresh_valid?Boolean (private)

Returns:

  • (Boolean)


28
29
30
# File 'app/models/sign_in/o_auth_session.rb', line 28

def refresh_valid?
  Time.zone.now < refresh_expiration
end

#session_max_valid?Boolean (private)

Returns:

  • (Boolean)


32
33
34
# File 'app/models/sign_in/o_auth_session.rb', line 32

def session_max_valid?
  Time.zone.now < refresh_creation + Constants::RefreshToken::SESSION_MAX_VALIDITY_LENGTH_DAYS
end

#user_attributes_hashObject



22
23
24
# File 'app/models/sign_in/o_auth_session.rb', line 22

def user_attributes_hash
  @user_attributes_hash ||= user_attributes.present? ? JSON.parse(user_attributes) : {}
end