1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Adding button to link accounts from user settings (#19792)

* Adding button to link accounts from user settings

* Only display button to link user accounts when at least one OAuth2 provider is active
This commit is contained in:
Mai-Lapyst
2022-05-29 02:03:17 +02:00
committed by GitHub
parent f2439b7e4c
commit 4698a1ec47
4 changed files with 42 additions and 5 deletions

View File

@@ -847,7 +847,17 @@ func SignInOAuthCallback(ctx *context.Context) {
}
if u == nil {
if !setting.Service.AllowOnlyInternalRegistration && setting.OAuth2Client.EnableAutoRegistration {
if ctx.Doer != nil {
// attach user to already logged in user
err = externalaccount.LinkAccountToUser(ctx.Doer, gothUser)
if err != nil {
ctx.ServerError("UserLinkAccount", err)
return
}
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
return
} else if !setting.Service.AllowOnlyInternalRegistration && setting.OAuth2Client.EnableAutoRegistration {
// create new user with details from oauth2 provider
var missingFields []string
if gothUser.UserID == "" {