Use Omniauthable user model with admin role

This commit is contained in:
pfischbeck committed 2019-02-03 18:00:42 +01:00
1 parent 52c8e3d7d2
commit b0f8bc5090
18 files changed
+167 -39

No files matched your search

-6
View File
@@ -1,6 +0,0 @@
class Admin < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
end
+11
View File
@@ -0,0 +1,11 @@
class User < ApplicationRecord
devise :omniauthable, :rememberable
enum role: [:user, :admin]
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.name = auth.info.name
end
end
end