X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/cb87f02642d0097ebc067ca1f9371dde274a41e3..fa77b55bd5efdb38ddfaad0911d871df5a226dd6:/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