-
Notifications
You must be signed in to change notification settings - Fork 15
How to integrate devise and rademade_admin
Yaroslav Senishyn edited this page May 23, 2017
·
2 revisions
Given separate model for different authentication methods:
class Identity < ApplicationRecord
belongs_to :user, autosave: true
devise :database_authenticatable, :lockable, :registerable, :recoverable, :rememberable,
:trackable, :validatable, :confirmable, :encryptable, :omniauthable,
omniauth_providers: [:facebook, :google_oauth2, :linkedin, :twitter, :vkontakte],
endIn order to give user access to admin panel you need to add three methods:
class User < ApplicationRecord
has_many :identities, dependent: :destroy
def self.get_by_email(email)
find_by(email: email)
end
def valid_password?(password)
email_identity.try(:valid_password?, password)
end
def email_identity
identities.find_by(provider: 'email')
end
end