Class: Authentication

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/authentication.rb

Overview

== Schema Information

Table name: authentications
Database name: primary

id :integer not null, primary key
google_auth_access_token :text
google_auth_refresh_token :text
google_calendar_status :string
google_calendar_status_checked_at :datetime
provider :string(255)
uid :string(255)
created_at :datetime not null
updated_at :datetime not null
account_id :integer

Indexes

index_authentications_on_account_id (account_id)
index_authentications_on_uid (uid)
provider_account_id (provider,account_id)
provider_uid (provider,uid)

Constant Summary collapse

PROVIDERS =
{
"facebook" => {:icon => "facebook", :name => "facebook"},
"google_oauth2" => {:icon => "google", :name => "google"},
"linkedin" => {:icon => "linkedin", :name => "linkedin"},
"apple" => {:icon => "apple", :name => "apple"},
"zoom" => {:icon => "video", :name => "zoom"}
}
SUPPORTED_PROVIDERS =

"google_apps" => "google_apps", "twitter" => => "twitter", :name => "twitter",

["facebook", "google_oauth2", "linkedin", "apple", "zoom"]

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Instance Attribute Summary collapse

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#uidObject (readonly)



36
# File 'app/models/authentication.rb', line 36

validates :uid, :uniqueness => {:scope => :provider }

Class Method Details

.extract_email_from_omniauth_hash(omniauth) ⇒ Object



47
48
49
# File 'app/models/authentication.rb', line 47

def self.extract_email_from_omniauth_hash(omniauth)
  omniauth.try(:[],'user_info').try(:[],'email') || omniauth.try(:[],'info').try(:[],'email')
end

.extract_name_from_omniauth_hash(omniauth) ⇒ Object



51
52
53
# File 'app/models/authentication.rb', line 51

def self.extract_name_from_omniauth_hash(omniauth)
  omniauth.try(:[],'user_info').try(:[],'name') || omniauth.try(:[],'info').try(:[],'name') || ( (omniauth.try(:[],'info').try(:[],'first_name').present? || omniauth.try(:[],'info').try(:[],'last_name').present?) ? [omniauth.try(:[],'info').try(:[],'first_name'), omniauth.try(:[],'info').try(:[],'last_name')].compact.join(' ') : nil)
end

.google_authActiveRecord::Relation<Authentication>

A relation of Authentications that are google auth. Active Record Scope

Returns:

See Also:



30
# File 'app/models/authentication.rb', line 30

scope :google_auth, -> { where(provider: 'google_oauth2') }

.zoom_authActiveRecord::Relation<Authentication>

A relation of Authentications that are zoom auth. Active Record Scope

Returns:

See Also:



31
# File 'app/models/authentication.rb', line 31

scope :zoom_auth, -> { where(provider: 'zoom') }

Instance Method Details

#accountAccount

Returns:

See Also:



28
# File 'app/models/authentication.rb', line 28

belongs_to :account, optional: true