# oauth_tokens_user_id_fkey (user_id => users.id)
#
-class OauthToken < ActiveRecord::Base
- belongs_to :client_application
- belongs_to :user
+class OauthToken < ApplicationRecord
+ belongs_to :client_application, :optional => true
+ belongs_to :user, :optional => true
scope :authorized, -> { where("authorized_at IS NOT NULL and invalidated_at IS NULL") }
end
def invalidate!
- update(:invalidated_at => Time.now)
+ update(:invalidated_at => Time.now.utc)
end
def authorized?