Module: Janus::Models::Confirmable

Extended by:
ActiveSupport::Concern
Defined in:
lib/janus/models/confirmable.rb

Overview

Confirmable

Confirms an account’s email by sending an email with an unique token. This is necessary to be sure the user can be contacted on that email.

IMPROVE: reconfirm whenever email changes.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#confirm!Object

Confirms the record.



32
33
34
35
36
# File 'lib/janus/models/confirmable.rb', line 32

def confirm!
  self.confirmation_token = self.confirmation_sent_at = nil
  self.confirmed_at = Time.now
  save
end

#confirmed?Boolean

Checks wether the email of this user if confirmed, or not.

Returns:

  • (Boolean)


39
40
41
# File 'lib/janus/models/confirmable.rb', line 39

def confirmed?
  confirmed_at?
end

#generate_confirmation_tokenObject

Generates the confirmation token, but won’t save the record.



26
27
28
29
# File 'lib/janus/models/confirmable.rb', line 26

def generate_confirmation_token
  self.confirmation_token = self.class.generate_token(:confirmation_token)
  self.confirmation_sent_at = Time.now
end