1
1
mirror of https://github.com/go-gitea/gitea synced 2025-12-07 05:18:29 +00:00

Fix oauth2 session gob register (#36017)

`gob.Register` must be called before Sessioner

Fix #36016
This commit is contained in:
wxiaoguang
2025-11-26 23:25:34 +08:00
committed by GitHub
parent abe2755f7a
commit 000c06d41b
9 changed files with 22 additions and 27 deletions

View File

@@ -277,8 +277,11 @@ type LinkAccountData struct {
GothUser goth.User
}
func init() {
gob.Register(LinkAccountData{}) // TODO: CHI-SESSION-GOB-REGISTER
}
func oauth2GetLinkAccountData(ctx *context.Context) *LinkAccountData {
gob.Register(LinkAccountData{})
v, ok := ctx.Session.Get("linkAccountData").(LinkAccountData)
if !ok {
return nil
@@ -287,7 +290,6 @@ func oauth2GetLinkAccountData(ctx *context.Context) *LinkAccountData {
}
func Oauth2SetLinkAccountData(ctx *context.Context, linkAccountData LinkAccountData) error {
gob.Register(LinkAccountData{})
return updateSession(ctx, nil, map[string]any{
"linkAccountData": linkAccountData,
})