mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
Raise an error if a api_username
is supplied and does not match the key
This commit is contained in:
@ -42,10 +42,12 @@ class Auth::DefaultCurrentUserProvider
|
||||
api_key = ApiKey.where(key: api_key_value).includes(:user).first
|
||||
if api_key.present?
|
||||
@env[API_KEY] = true
|
||||
api_username = request["api_username"]
|
||||
|
||||
if api_key.user.present?
|
||||
raise Discourse::InvalidAccess.new if api_username && (api_key.user.username_lower != api_username.downcase)
|
||||
current_user = api_key.user
|
||||
elsif api_username = request["api_username"]
|
||||
elsif api_username
|
||||
current_user = User.where(username_lower: api_username.downcase).first
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user