Files
codeocean/app/models/internal_user.rb
2021-07-12 13:27:41 +02:00

36 lines
708 B
Ruby

# frozen_string_literal: true
class InternalUser < User
authenticates_with_sorcery!
attr_accessor :validate_password
validates :email, presence: true, uniqueness: true
validates :password, confirmation: true, if: -> { password_void? && validate_password? }, on: :update, presence: true
validates :role, inclusion: {in: ROLES}
def activated?
activation_state == 'active'
end
def password_void?
activation_token? || reset_password_token?
end
private :password_void?
def validate_password?
return true if @validate_password.nil?
@validate_password
end
private :validate_password?
def teacher?
role == 'teacher'
end
def displayname
name
end
end