mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: allow system api to target users via external id or user id
usage ?api_key=XYZ&api_user_external_id=ABC usage ?api_key=XYZ&api_user_id=123
This commit is contained in:
parent
a2c561bbde
commit
215c0d5569
2 changed files with 17 additions and 0 deletions
|
@ -259,6 +259,10 @@ class Auth::DefaultCurrentUserProvider
|
|||
api_key.user if !api_username || (api_key.user.username_lower == api_username.downcase)
|
||||
elsif api_username
|
||||
User.find_by(username_lower: api_username.downcase)
|
||||
elsif user_id = request["api_user_id"]
|
||||
User.find_by(id: user_id.to_i)
|
||||
elsif external_id = request["api_user_external_id"]
|
||||
SingleSignOnRecord.find_by(external_id: external_id.to_s).try(:user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue