Skip to content

Commit

Permalink
Fix NPE when editing OAuth2 applications (go-gitea#27078)
Browse files Browse the repository at this point in the history
Fixes go-gitea#27072

It looks like there are some cases where `ContextUser` is not set here

---------

Co-authored-by: techknowlogick <[email protected]>
  • Loading branch information
JakobDev and techknowlogick authored Sep 16, 2023
1 parent f3f4458 commit efecbba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routers/web/user/setting/oauth2_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -68,6 +67,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) {
ctx.ServerError("GenerateClientSecret", err)
return
}

oa.renderEditPage(ctx)
}

Expand Down

0 comments on commit efecbba

Please sign in to comment.