Sha256: 233ca311ab6b722905325bc09626124a252c3f1a4bc550bfd76ea6935f4820f2

Contents?: true

Size: 651 Bytes

Versions: 6

Compression:

Stored size: 651 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,
        :confirmable

  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

  def serializable_hash(options={})
    options ||= {}
    options[:except] ||= [:tokens]
    super(options)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise_token_auth-0.1.12 app/models/user.rb
devise_token_auth-0.1.11 app/models/user.rb
devise_token_auth-0.1.10 app/models/user.rb
devise_token_auth-0.1.9 app/models/user.rb
devise_token_auth-0.1.8 app/models/user.rb
devise_token_auth-0.1.7 app/models/user.rb