demarches-normaliennes/app/models/administration.rb

21 lines
658 B
Ruby
Raw Normal View History

2018-03-06 13:44:29 +01:00
class Administration < ApplicationRecord
2016-02-23 16:51:24 +01:00
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable, :validatable, :omniauthable, :lockable, :async, omniauth_providers: [:github]
2017-12-20 15:27:33 +01:00
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
2019-08-09 11:41:36 +02:00
user
end
2016-02-23 16:51:24 +01:00
end