X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eb0f9ff63d5ad5d91ea941420e094dd2980df094..0d1147e7812c88ae6504a0b090a753375fa9e9f8:/app/models/access_token.rb diff --git a/app/models/access_token.rb b/app/models/access_token.rb index b773310ce..1a5ff8553 100644 --- a/app/models/access_token.rb +++ b/app/models/access_token.rb @@ -1,10 +1,57 @@ -class AccessToken client_applications.id) +# oauth_tokens_user_id_fkey (user_id => users.id) +# + +class AccessToken < OauthToken + belongs_to :user + belongs_to :client_application + + scope :valid, -> { where(:invalidated_at => nil) } + + validates :user, :secret, :presence => true + before_create :set_authorized_at - -protected - + + def includes_scope?(scope) + self[:"allow_#{scope}"] + end + + protected + def set_authorized_at self.authorized_at = Time.now end -end \ No newline at end of file +end