Skip to content

Commit efecbba

Browse files
Fix NPE when editing OAuth2 applications (#27078)
Fixes #27072 It looks like there are some cases where `ContextUser` is not set here --------- Co-authored-by: techknowlogick <[email protected]>
1 parent f3f4458 commit efecbba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

routers/web/user/setting/oauth2_common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ func (oa *OAuth2CommonHandlers) renderEditPage(ctx *context.Context) {
2727
app := ctx.Data["App"].(*auth.OAuth2Application)
2828
ctx.Data["FormActionPath"] = fmt.Sprintf("%s/%d", oa.BasePathEditPrefix, app.ID)
2929

30-
if ctx.ContextUser.IsOrganization() {
31-
err := shared_user.LoadHeaderCount(ctx)
32-
if err != nil {
30+
if ctx.ContextUser != nil && ctx.ContextUser.IsOrganization() {
31+
if err := shared_user.LoadHeaderCount(ctx); err != nil {
3332
ctx.ServerError("LoadHeaderCount", err)
3433
return
3534
}
@@ -68,6 +67,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) {
6867
ctx.ServerError("GenerateClientSecret", err)
6968
return
7069
}
70+
7171
oa.renderEditPage(ctx)
7272
}
7373

0 commit comments

Comments
 (0)