]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/access_token.rb
Add Bootstrap styling to changeset node/way/relation page links
[rails.git] / app / models / access_token.rb
index e5ba2e240916cce272059fa4abd316501ed785ac..d2c0dba1ce85a93e39b7838f0e6b1bcbd24f88e5 100644 (file)
@@ -36,8 +36,8 @@
 #
 
 class AccessToken < OauthToken
 #
 
 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) }
 
 
   scope :valid, -> { where(:invalidated_at => nil) }
 
@@ -45,9 +45,13 @@ class AccessToken < OauthToken
 
   before_create :set_authorized_at
 
 
   before_create :set_authorized_at
 
+  def includes_scope?(scope)
+    self[:"allow_#{scope}"]
+  end
+
   protected
 
   def set_authorized_at
   protected
 
   def set_authorized_at
-    self.authorized_at = Time.now
+    self.authorized_at = Time.now.utc
   end
 end
   end
 end