Sha256: 7a61507632a818f8f858094051ee87a9182bccff8dd2395db8cbecb91cbafc01
Contents?: true
Size: 623 Bytes
Versions: 11
Compression:
Stored size: 623 Bytes
Contents
class Marty::Token < Marty::Base belongs_to :user validates :value, uniqueness: true before_create :delete_previous_tokens, :generate_new_token # @@validity_time = 1.day def generate_new_token self.value = Token.generate_token_value end # # Return true if token has expired # def expired? # return Time.now > self.created_on + @@validity_time # end private def self.generate_token_value SecureRandom.hex(20) end # Removes obsolete tokens def delete_previous_tokens if user && !Marty::Util.db_in_recovery? Token.delete_all(['user_id = ?', user.id]) end end end
Version data entries
11 entries across 11 versions & 1 rubygems