X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d227589a6336999c38bffc5e11655100b9a4630a..c32f6dd4fffe1d2b5fc34f42e447e7b5c8fc5b92:/app/models/access_token.rb?ds=sidebyside diff --git a/app/models/access_token.rb b/app/models/access_token.rb index b773310ce..d2c0dba1c 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, :optional => true + belongs_to :client_application, :optional => true + + 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 + self.authorized_at = Time.now.utc end -end \ No newline at end of file +end