1
0
Fork 0
forked from forgejo/forgejo

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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 == "" {