mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: sendgrid webhooks
This commit is contained in:
parent
0f8b4dcc86
commit
9704603fab
7 changed files with 87 additions and 7 deletions
|
@ -120,12 +120,11 @@ class Auth::DefaultCurrentUserProvider
|
|||
protected
|
||||
|
||||
def lookup_api_user(api_key_value, request)
|
||||
api_key = ApiKey.where(key: api_key_value).includes(:user).first
|
||||
if api_key
|
||||
if api_key = ApiKey.where(key: api_key_value).includes(:user).first
|
||||
api_username = request["api_username"]
|
||||
|
||||
if api_key.allowed_ips.present? && !api_key.allowed_ips.any?{|ip| ip.include?(request.ip)}
|
||||
Rails.logger.warn("Unauthorized API access: #{api_username} ip address: #{request.ip}")
|
||||
if api_key.allowed_ips.present? && !api_key.allowed_ips.any? { |ip| ip.include?(request.ip) }
|
||||
Rails.logger.warn("[Unauthorized API Access] username: #{api_username}, IP address: #{request.ip}")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue