mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-06 23:44:20 -04:00
Fix goth user infer bug (#15821)
This commit is contained in:
parent
e5723d6556
commit
3656a2a672
@ -983,11 +983,16 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
|||||||
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/link_account_signin"
|
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/link_account_signin"
|
||||||
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/link_account_signup"
|
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/link_account_signup"
|
||||||
|
|
||||||
gothUser := ctx.Session.Get("linkAccountGothUser")
|
gothUserInterface := ctx.Session.Get("linkAccountGothUser")
|
||||||
if gothUser == nil {
|
if gothUserInterface == nil {
|
||||||
ctx.ServerError("UserSignUp", errors.New("not in LinkAccount session"))
|
ctx.ServerError("UserSignUp", errors.New("not in LinkAccount session"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
gothUser, ok := gothUserInterface.(goth.User)
|
||||||
|
if !ok {
|
||||||
|
ctx.ServerError("UserSignUp", fmt.Errorf("session linkAccountGothUser type is %t but not goth.User", gothUserInterface))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(http.StatusOK, tplLinkAccount)
|
ctx.HTML(http.StatusOK, tplLinkAccount)
|
||||||
@ -1049,7 +1054,7 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loginSource, err := models.GetActiveOAuth2LoginSourceByName(gothUser.(goth.User).Provider)
|
loginSource, err := models.GetActiveOAuth2LoginSourceByName(gothUser.Provider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("CreateUser", err)
|
ctx.ServerError("CreateUser", err)
|
||||||
}
|
}
|
||||||
@ -1061,10 +1066,10 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
|||||||
IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
|
IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
|
||||||
LoginType: models.LoginOAuth2,
|
LoginType: models.LoginOAuth2,
|
||||||
LoginSource: loginSource.ID,
|
LoginSource: loginSource.ID,
|
||||||
LoginName: gothUser.(goth.User).UserID,
|
LoginName: gothUser.UserID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !createAndHandleCreatedUser(ctx, tplLinkAccount, form, u, gothUser.(*goth.User), false) {
|
if !createAndHandleCreatedUser(ctx, tplLinkAccount, form, u, &gothUser, false) {
|
||||||
// error already handled
|
// error already handled
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user