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