diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 5786118f50d..5ac03e4a746 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -27,9 +27,8 @@ 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 { + if ctx.ContextUser != nil && ctx.ContextUser.IsOrganization() { + if err := shared_user.LoadHeaderCount(ctx); err != nil { ctx.ServerError("LoadHeaderCount", err) return } @@ -68,6 +67,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) { ctx.ServerError("GenerateClientSecret", err) return } + oa.renderEditPage(ctx) }