module Tyrant::Authenticatable::Confirm
Public Instance Methods
confirmable!()
click to toggle source
# File lib/tyrant/authenticatable.rb, line 18 def confirmable! auth_meta_data.confirmation_token = "asdfasdfasfasfasdfasdf" auth_meta_data.confirmation_created_at = DateTime.now self end
confirmable?(token=false)
click to toggle source
without token, this decides whether the user model can be activated (e.g. via “set a password”). with token, this additionally tests if the token is correct.
# File lib/tyrant/authenticatable.rb, line 26 def confirmable?(token=false) persisted_token = auth_meta_data.confirmation_token # TODO: add expiry etc. return false unless (persisted_token.is_a?(String) and persisted_token.size > 0) return compare_token(token) unless token==false true end
confirmation_token()
click to toggle source
# File lib/tyrant/authenticatable.rb, line 46 def confirmation_token auth_meta_data.confirmation_token end
confirmed!(confirmed_at=DateTime.now)
click to toggle source
# File lib/tyrant/authenticatable.rb, line 41 def confirmed!(confirmed_at=DateTime.now) auth_meta_data.confirmation_token = nil auth_meta_data.confirmed_at = confirmed_at # TODO: test optional arg. end
confirmed?()
click to toggle source
alias_method :confirmed?, :confirmable?
# File lib/tyrant/authenticatable.rb, line 37 def confirmed? not auth_meta_data.confirmed_at.nil? end
Private Instance Methods
compare_token(token)
click to toggle source
# File lib/tyrant/authenticatable.rb, line 51 def compare_token(token) token == auth_meta_data.confirmation_token end