Skip to content

Commit 584cf85

Browse files
fix oauth2 error
1 parent 68ef8ee commit 584cf85

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

routers/web/shared/user/header.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package user
55

66
import (
7-
"errors"
7+
"fmt"
88
"net/url"
99

1010
"code.gitea.io/gitea/models/db"
@@ -138,15 +138,15 @@ func FindOwnerProfileReadme(ctx *context.Context, doer *user_model.User, optProf
138138
}
139139

140140
func RenderUserOrgHeader(ctx *context.Context) error {
141+
if ctx.ContextUser == nil {
142+
return fmt.Errorf("ctx.ContextUser is nil")
143+
}
141144
if err := LoadHeaderCount(ctx); err != nil {
142145
return err
143146
}
144147
_, profileReadmeBlob := FindOwnerProfileReadme(ctx, ctx.Doer)
145148
ctx.Data["HasUserProfileReadme"] = profileReadmeBlob != nil
146149

147-
if ctx.ContextUser == nil {
148-
return errors.New("ctx.ContextUser is nil")
149-
}
150150
if ctx.ContextUser.IsOrganization() {
151151
if ctx.Data["HasOrgProfileReadme"] == nil {
152152
if _, err := PrepareOrgHeader(ctx); err != nil {

routers/web/user/setting/oauth2_common.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ 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 err := shared_user.RenderUserOrgHeader(ctx); err != nil {
31-
ctx.ServerError("RenderUserOrgHeader", err)
32-
return
30+
if ctx.ContextUser != nil && ctx.ContextUser.IsOrganization() {
31+
if err := shared_user.RenderUserOrgHeader(ctx); err != nil {
32+
ctx.ServerError("RenderUserOrgHeader", err)
33+
return
34+
}
3335
}
3436

3537
ctx.HTML(http.StatusOK, oa.TplAppEdit)

0 commit comments

Comments
 (0)