|
|
@ -1,16 +1,17 @@ |
|
|
|
class User < ApplicationRecord |
|
|
|
class User < ApplicationRecord |
|
|
|
# Include default devise modules. Others available are: |
|
|
|
# Include default devise modules. Others available are: |
|
|
|
# :omniauthable |
|
|
|
# :omniauthable |
|
|
|
include Helpers::Email |
|
|
|
devise :database_authenticatable, :recoverable, :rememberable, |
|
|
|
devise :database_authenticatable, :recoverable, :rememberable, :validatable, |
|
|
|
|
|
|
|
:trackable, :lockable, :two_factor_authenticatable, :confirmable, :timeoutable |
|
|
|
:trackable, :lockable, :two_factor_authenticatable, :confirmable, :timeoutable |
|
|
|
|
|
|
|
|
|
|
|
belongs_to :organisation |
|
|
|
belongs_to :organisation |
|
|
|
has_many :owned_case_logs, through: :organisation, dependent: :delete_all |
|
|
|
has_many :owned_case_logs, through: :organisation, dependent: :delete_all |
|
|
|
has_many :managed_case_logs, through: :organisation |
|
|
|
has_many :managed_case_logs, through: :organisation |
|
|
|
|
|
|
|
|
|
|
|
validate :validate_email |
|
|
|
validates :name, presence: true |
|
|
|
validates :name, :email, presence: true |
|
|
|
validates :email, presence: true, uniqueness: true |
|
|
|
|
|
|
|
validates_format_of :email, with: Devise.email_regexp |
|
|
|
|
|
|
|
validates_length_of :password, within: Devise.password_length, allow_blank: true |
|
|
|
|
|
|
|
|
|
|
|
has_paper_trail ignore: %w[last_sign_in_at |
|
|
|
has_paper_trail ignore: %w[last_sign_in_at |
|
|
|
current_sign_in_at |
|
|
|
current_sign_in_at |
|
|
|