40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
# == 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
|
|
#
|
|
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?
|
|
user.invite_administrateur!(id)
|
|
end
|
|
|
|
user
|
|
end
|
|
end
|