]> git.openstreetmap.org Git - rails.git/blob - app/models/user_token.rb
Added support for 2 more secondary wikidata tag links
[rails.git] / app / models / user_token.rb
1 # == Schema Information
2 #
3 # Table name: user_tokens
4 #
5 #  id      :integer          not null, primary key
6 #  user_id :integer          not null
7 #  token   :string           not null
8 #  expiry  :datetime         not null
9 #  referer :text
10 #
11 # Indexes
12 #
13 #  user_tokens_token_idx    (token) UNIQUE
14 #  user_tokens_user_id_idx  (user_id)
15 #
16 # Foreign Keys
17 #
18 #  user_tokens_user_id_fkey  (user_id => users.id)
19 #
20
21 class UserToken < ActiveRecord::Base
22   belongs_to :user
23
24   after_initialize :set_defaults
25
26   def expired?
27     expiry < Time.now
28   end
29
30   private
31
32   def set_defaults
33     self.token = OSM.make_token if token.blank?
34     self.expiry = 1.week.from_now if expiry.blank?
35   end
36 end