aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/auth
diff options
context:
space:
mode:
authorMai-Lapyst <67418776+Mai-Lapyst@users.noreply.github.com>2022-05-29 02:03:17 +0200
committerGitHub <noreply@github.com>2022-05-29 02:03:17 +0200
commit4698a1ec47847da177b6df2738336f039057d585 (patch)
treea6fb537d524522b13d78764504a8e11ffcf9cdbf /routers/web/auth
parentf2439b7e4c47de018e1678ceaa434e4b3d734a83 (diff)
downloadgitea-4698a1ec47847da177b6df2738336f039057d585.tar.gz
gitea-4698a1ec47847da177b6df2738336f039057d585.zip
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
Diffstat (limited to 'routers/web/auth')
-rw-r--r--routers/web/auth/oauth.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 9aa31c1c02..f646615968 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -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 == "" {