Module: Devise::Models::Certifiable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise_certifiable/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#active_for_authentication?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/devise_certifiable/model.rb', line 42

def active_for_authentication?
  super && certified?
end

#certified?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/devise_certifiable/model.rb', line 28

def certified?
  !!certified_at
end

#certify!(certification_authority) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/devise_certifiable/model.rb', line 13

def certify!(certification_authority)
  unless_certified do
    unless certification_authority.blank?
      self.certification_token = nil
      self.certified_at = Time.now
      self.certified_by = certification_authority
      save(:validate => false)
      send_confirmation_instructions if confirmation_required?
    else
      self.errors.add(:certified_by, :certification_authority_missing)
      false
    end
  end
end

#inactive_messageObject



46
47
48
# File 'lib/devise_certifiable/model.rb', line 46

def inactive_message
  !certified? ? :uncertified : super
end

#request_certificationObject

Deliver certification request to certification authority



33
34
35
36
37
38
39
40
# File 'lib/devise_certifiable/model.rb', line 33

def request_certification
  if self.respond_to?(:invite!) && self.invitation_token.present?
    certify!(self.invited_by)
  else
    generate_certification_token! if self.certification_token.nil?
    ::Devise.mailer.certification_request(self).deliver
  end
end