Commit 357f498
Changed files (5)
app
controllers
models
db
spec
requests
app/controllers/oauths_controller.rb
@@ -21,6 +21,7 @@ class OauthsController < ApplicationController
def token
response.headers['Cache-Control'] = 'no-store'
response.headers['Pragma'] = 'no-cache'
+ Authorization.find_by!(code: params[:code]).revoke!
render json: {
access_token: SecureRandom.hex(20),
token_type: 'access',
db/schema.rb
@@ -17,6 +17,7 @@ ActiveRecord::Schema.define(version: 2018_09_05_020708) do
t.integer "client_id"
t.string "code", null: false
t.datetime "expired_at", null: false
+ t.datetime "revoked_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["client_id"], name: "index_authorizations_on_client_id"
spec/requests/oauth_spec.rb
@@ -72,6 +72,7 @@ RSpec.describe '/oauth' do
specify { expect(json[:token_type]).to be_present }
specify { expect(json[:expires_in]).to be_present }
specify { expect(json[:refresh_token]).to be_present }
+ specify { expect(authorization.reload).to be_revoked }
end
end
end