fix(middleware): rate-limit key uses optional user ID pointer
This commit is contained in:
1 parent
be64e7c8d2
commit
98985db537
1 file changed
+2
-2
@@ -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