fix(middleware): rate-limit key uses optional user ID pointer
This commit is contained in:
@@ -327,8 +327,8 @@ func GetSecureClientIP(r *http.Request) string {
|
|||||||
func GetKey(r *http.Request) string {
|
func GetKey(r *http.Request) string {
|
||||||
ip := GetSecureClientIP(r)
|
ip := GetSecureClientIP(r)
|
||||||
|
|
||||||
if userID := GetUserIDFromContext(r.Context()); userID != 0 {
|
if userID := GetUserIDFromContext(r.Context()); userID != nil {
|
||||||
return fmt.Sprintf("user:%d:ip:%s", userID, ip)
|
return fmt.Sprintf("user:%d:ip:%s", *userID, ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("ip:%s", ip)
|
return fmt.Sprintf("ip:%s", ip)
|
||||||
|
|||||||
Reference in New Issue
Block a user