From 86827836fcebe129e9acfa7c7a6e431e6a121b8a Mon Sep 17 00:00:00 2001 From: JakobDev Date: Thu, 14 Sep 2023 13:07:40 +0200 Subject: [PATCH 1/2] Fix OAuth2 500 error --- routers/web/user/setting/oauth2_common.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 5786118f50d97..7f4d8b842c0eb 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -27,11 +27,13 @@ func (oa *OAuth2CommonHandlers) renderEditPage(ctx *context.Context) { app := ctx.Data["App"].(*auth.OAuth2Application) ctx.Data["FormActionPath"] = fmt.Sprintf("%s/%d", oa.BasePathEditPrefix, app.ID) - if ctx.ContextUser.IsOrganization() { - err := shared_user.LoadHeaderCount(ctx) - if err != nil { - ctx.ServerError("LoadHeaderCount", err) - return + if ctx.ContextUser != nil { + if ctx.ContextUser.IsOrganization() { + err := shared_user.LoadHeaderCount(ctx) + if err != nil { + ctx.ServerError("LoadHeaderCount", err) + return + } } } @@ -68,6 +70,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) { ctx.ServerError("GenerateClientSecret", err) return } + oa.renderEditPage(ctx) } From 6da7aaded837611385d3593d9040fec31d27626c Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 15 Sep 2023 10:08:43 -0400 Subject: [PATCH 2/2] Update routers/web/user/setting/oauth2_common.go Co-authored-by: wxiaoguang --- routers/web/user/setting/oauth2_common.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 7f4d8b842c0eb..5ac03e4a7467b 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -27,13 +27,10 @@ func (oa *OAuth2CommonHandlers) renderEditPage(ctx *context.Context) { app := ctx.Data["App"].(*auth.OAuth2Application) ctx.Data["FormActionPath"] = fmt.Sprintf("%s/%d", oa.BasePathEditPrefix, app.ID) - if ctx.ContextUser != nil { - if ctx.ContextUser.IsOrganization() { - err := shared_user.LoadHeaderCount(ctx) - if err != nil { - ctx.ServerError("LoadHeaderCount", err) - return - } + if ctx.ContextUser != nil && ctx.ContextUser.IsOrganization() { + if err := shared_user.LoadHeaderCount(ctx); err != nil { + ctx.ServerError("LoadHeaderCount", err) + return } }