mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
id is optional if already specified in header
This commit is contained in:
parent
be0fd5b4cc
commit
1d281e02c7
2 changed files with 16 additions and 1 deletions
|
@ -90,14 +90,18 @@ class UserApiKeysController < ApplicationController
|
|||
end
|
||||
|
||||
def revoke
|
||||
revoke_key = find_key
|
||||
revoke_key = find_key if params[:id]
|
||||
|
||||
if current_key = request.env['HTTP_USER_API_KEY']
|
||||
request_key = UserApiKey.find_by(key: current_key)
|
||||
revoke_key ||= request_key
|
||||
if request_key && request_key.id != revoke_key.id && !request_key.write
|
||||
raise Discourse::InvalidAccess
|
||||
end
|
||||
end
|
||||
|
||||
raise Discourse::NotFound unless revoke_key
|
||||
|
||||
revoke_key.update_columns(revoked_at: Time.zone.now)
|
||||
|
||||
render json: success_json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue