X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/effb1b7f4170bb7244c4dfffcbe6134fe00e2bc4..2baff0463547693bfcfdca7dea9055aa26459a18:/app/models/user_token.rb?ds=sidebyside diff --git a/app/models/user_token.rb b/app/models/user_token.rb index 0d1e16e8a..fbd276a6f 100644 --- a/app/models/user_token.rb +++ b/app/models/user_token.rb @@ -2,8 +2,8 @@ # # Table name: user_tokens # -# id :integer not null, primary key -# user_id :integer not null +# id :bigint(8) not null, primary key +# user_id :bigint(8) not null # token :string not null # expiry :datetime not null # referer :text @@ -18,13 +18,15 @@ # user_tokens_user_id_fkey (user_id => users.id) # -class UserToken < ActiveRecord::Base +class UserToken < ApplicationRecord belongs_to :user + scope :unexpired, -> { where("expiry >= now()") } + after_initialize :set_defaults def expired? - expiry < Time.now + expiry < Time.now.utc end private