Sha256: dd3ce9746942a54fedff6a506cd179765a03086aa63744f6609c69414ab0aa23
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
module Jobshop class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable belongs_to :team, optional: true has_one :default_dashboard, class_name: "Jobshop::Dashboard", through: :team has_many :session_activations, dependent: :destroy validates :email, presence: { if: :email_required? }, format: { if: :email_required?, with: /\A[^@\s]+@[^@\s]+\z/ }, uniqueness: { if: :email_changed?, scope: :team_id } validates :password, presence: { if: :password_required? }, confirmation: { if: :password_required? } def self.find_for_authentication(warden_conditions) where(email: warden_conditions[:email], team_id: warden_conditions[:team_id]).first end def onboard? # TODO: Implement this correctly. false end def activate_session session_activations.activate(SecureRandom.hex).activation_token end def exclusive_session(id) session_activations.exclusive(id) end def session_active?(id) session_activations.active?(id) end private def generate_email_authentication_token loop do token = Devise.friendly_token break token unless Jobshop::User.where(email_authentication_token: token).first end end def password_required? !persisted? || !password.nil? || !password_confirmation.nil? end def email_required? true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jobshop-0.0.113 | app/models/jobshop/user.rb |
jobshop-0.0.109 | app/models/jobshop/user.rb |