Sha256: 149dd4cbbfd2a49bebe107c97ec162b24fd019356473ab41671a988de49b08ce

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
        :recoverable, :rememberable, :trackable, :validatable

  serialize :tokens, JSON

  def valid_token?(client_id, token)
    return false unless self.tokens[client_id]['expiry'] > 2.weeks.ago
    return false unless BCrypt::Password.new(self.tokens[client_id]['token']) == token

    return true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_token_auth-0.1.6 app/models/user.rb
devise_token_auth-0.1.5 app/models/user.rb