2016-02-23 16:51:24 +01:00
|
|
|
class Administration < ActiveRecord::Base
|
|
|
|
# Include default devise modules. Others available are:
|
|
|
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
2017-12-20 15:27:33 +01:00
|
|
|
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:github]
|
|
|
|
|
|
|
|
def self.from_omniauth(params)
|
|
|
|
find_by(email: params["info"]["email"])
|
|
|
|
end
|
2018-01-11 14:17:50 +01:00
|
|
|
|
|
|
|
def invite_admin(email)
|
|
|
|
administrateur = Administrateur.new({
|
|
|
|
email: email,
|
2018-01-15 22:13:52 +01:00
|
|
|
active: false
|
2018-01-11 14:17:50 +01:00
|
|
|
})
|
|
|
|
administrateur.password = administrateur.password_confirmation = SecureRandom.hex
|
|
|
|
|
|
|
|
if administrateur.save
|
|
|
|
AdministrationMailer.new_admin_email(administrateur, self).deliver_now!
|
|
|
|
administrateur.invite!
|
|
|
|
end
|
|
|
|
|
|
|
|
administrateur
|
|
|
|
end
|
2016-02-23 16:51:24 +01:00
|
|
|
end
|