demarches-normaliennes/app/models/administration.rb
2019-08-20 12:20:12 +02:00

20 lines
658 B
Ruby

class Administration < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, :lockable, :async, omniauth_providers: [:github]
def self.from_omniauth(params)
find_by(email: params["info"]["email"])
end
def invite_admin(email)
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
if user.valid?
AdministrationMailer.new_admin_email(user.administrateur, self).deliver_later
user.invite_administrateur!(id)
end
user
end
end