2020-08-06 16:35:45 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: administrations
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# current_sign_in_at :datetime
|
|
|
|
# current_sign_in_ip :string
|
|
|
|
# email :string default(""), not null
|
|
|
|
# encrypted_password :string default(""), not null
|
|
|
|
# failed_attempts :integer default(0), not null
|
|
|
|
# last_sign_in_at :datetime
|
|
|
|
# last_sign_in_ip :string
|
|
|
|
# locked_at :datetime
|
|
|
|
# remember_created_at :datetime
|
|
|
|
# reset_password_sent_at :datetime
|
|
|
|
# reset_password_token :string
|
|
|
|
# sign_in_count :integer default(0), not null
|
|
|
|
# unlock_token :string
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
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
|
2020-11-03 17:36:35 +01:00
|
|
|
devise :database_authenticatable, :rememberable, :trackable, :validatable, :lockable, :async
|
2018-01-11 14:17:50 +01:00
|
|
|
|
|
|
|
def invite_admin(email)
|
2019-08-20 12:07:07 +02:00
|
|
|
user = User.create_or_promote_to_administrateur(email, SecureRandom.hex)
|
2018-01-11 14:17:50 +01:00
|
|
|
|
2019-08-20 12:07:07 +02:00
|
|
|
if user.valid?
|
|
|
|
user.invite_administrateur!(id)
|
2018-01-11 14:17:50 +01:00
|
|
|
end
|
|
|
|
|
2019-08-09 11:41:36 +02:00
|
|
|
user
|
2018-01-11 14:17:50 +01:00
|
|
|
end
|
2016-02-23 16:51:24 +01:00
|
|
|
end
|