Skip to content

Commit afff9b4

Browse files
committed
OCPBUGS-64943: Make GetUserFromRequestContext more nil safe
1 parent dca91cd commit afff9b4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/auth/user.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ const (
99
)
1010

1111
func GetUserFromRequestContext(r *http.Request) *User {
12-
user, ok := r.Context().Value(UserContextKey).(*User)
13-
if !ok {
14-
return nil
12+
if user, ok := r.Context().Value(UserContextKey); ok {
13+
return user.(*User)
1514
}
16-
return user
15+
return nil
1716
}

0 commit comments

Comments
 (0)