From aec65d8e19713f441c46df2128fdfb3c4d336c2f Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Fri, 24 Feb 2023 16:27:01 +0100 Subject: [PATCH] Make the nickname claim conditional on the openid scope too This is only needed for OIDC anyway --- handlers/user/info.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/handlers/user/info.go b/handlers/user/info.go index 4ef420c..f412dc8 100644 --- a/handlers/user/info.go +++ b/handlers/user/info.go @@ -61,9 +61,10 @@ func UserInfo(ctx *gin.Context) { if s == "openid" { userinfoRes["sub"] = *tokenInfo.Sub - } else if s == "username" { - // Add "nickname" field for OIDC compatibility - userinfoRes["nickname"] = userinfoRes[s] + if value, ok := (*userinfo)["username"]; ok { + // Add "nickname" field for OIDC compatibility + userinfoRes["nickname"] = value + } } } }