demarches-normaliennes/app/models/administration.rb
2018-01-18 10:55:08 +01:00

24 lines
741 B
Ruby

class Administration < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:github]
def self.from_omniauth(params)
find_by(email: params["info"]["email"])
end
def invite_admin(email)
administrateur = Administrateur.new({
email: email,
active: false
})
administrateur.password = administrateur.password_confirmation = SecureRandom.hex
if administrateur.save
AdministrationMailer.new_admin_email(administrateur, self).deliver_now!
administrateur.invite!
end
administrateur
end
end