X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b2a8df0bd73f1031dcf4684e084897a28b117345..ab4de87d1eef4546a96738154cf81b7d7f72d988:/app/models/access_token.rb diff --git a/app/models/access_token.rb b/app/models/access_token.rb index e5ba2e240..d2c0dba1c 100644 --- a/app/models/access_token.rb +++ b/app/models/access_token.rb @@ -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