summaryrefslogtreecommitdiff
path: root/users/app/models/token.rb
blob: 514b97f6f7f674fdbe71b6a15582148f4506a1ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Token < CouchRest::Model::Base

  use_database :tokens

  property :user_id, String, accessible: false

  validates :user_id, presence: true

  def user
    User.find(self.user_id)
  end

  def initialize(*args)
    super
    self.id = SecureRandom.urlsafe_base64(32).gsub(/^_*/, '')
  end

  design do
  end
end