]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/access_token.rb
Bump qs from 6.11.2 to 6.12.0
[rails.git] / app / models / access_token.rb
index e5ba2e240916cce272059fa4abd316501ed785ac..d2c0dba1ce85a93e39b7838f0e6b1bcbd24f88e5 100644 (file)
@@ -36,8 +36,8 @@
 #
 
 class AccessToken < OauthToken
-  belongs_to :user
-  belongs_to :client_application
+  belongs_to :user, :optional => true
+  belongs_to :client_application, :optional => true
 
   scope :valid, -> { where(:invalidated_at => nil) }
 
@@ -45,9 +45,13 @@ class AccessToken < OauthToken
 
   before_create :set_authorized_at
 
+  def includes_scope?(scope)
+    self[:"allow_#{scope}"]
+  end
+
   protected
 
   def set_authorized_at
-    self.authorized_at = Time.now
+    self.authorized_at = Time.now.utc
   end
 end