mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: sendgrid webhooks
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user