]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/access_token.rb
Remove obsolete pt-BR.yml translation file
[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