dpc-admin/app/models/internal_user.rb
# frozen_string_literal: true
class InternalUser < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable, :registerable
devise :database_authenticatable,
:trackable, :timeoutable,
:omniauthable, omniauth_providers: %i[github]
validates :uid, uniqueness: { scope: :provider }
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0, 20]
user.name = auth.info.name
user.github_nickname = auth.info.nickname
end
end
end