mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 02:28:50 +01:00
Use Omniauthable user model with admin role
This commit is contained in:
@@ -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
app/models/user.rb
Normal file
11
app/models/user.rb
Normal 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
|
||||
Reference in New Issue
Block a user