Sha256: c8bd3f424b2708b3b3d5d9ea45bd9370ea3fff76665de24932699f55e3a0b95c
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
class Member < ActiveRecord::Base belongs_to :user belongs_to :organization has_many :user_vacation_infos belongs_to :vacation has_one :user_vacation_info has_many :member_devices has_and_belongs_to_many :roles rolify devise :invitable, :lockable attr_reader :raw_invitation_token after_invitation_accepted :email_invited_by def email_invited_by self.invitation_token = '' self.invitation_accepted_at = Time.now self.save(validate: false) end def invite_user! generate_invitation_token! invitation_created_at = Time.now invitation_sent_at = Time.now self.save(validate: false) user.send_devise_notification(:invitation_instructions, self.raw_invitation_token) end # when you lock access, you could pass the next hash # `{ send_instructions: false } as option`. def lock_access!(opts = { }) self.locked_at = Time.now.utc if unlock_strategy_enabled?(:email) && opts.fetch(:send_instructions, true) send_unlock_instructions else save(validate: false) end end # Unlock a user by cleaning locked_at and failed_attempts. def unlock_access! self.locked_at = nil self.failed_attempts = 0 if respond_to?(:failed_attempts=) self.unlock_token = nil if respond_to?(:unlock_token=) save(validate: false) end # Verifies whether a user is locked or not. def access_locked? !!locked_at && !lock_expired? end def self.enabled! member_org_ids = self.where(disabled: false).map(&:organization_id) Organization.where(id: member_org_ids) end def disable! self.update_attributes(disabled: true) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pshq_engine-0.1.6 | app/models/member.rb |
pshq_engine-0.1.5 | app/models/member.rb |
pshq_engine-0.0.1 | app/models/member.rb |