diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 6855e0376..a0babf7a1 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -9,7 +9,6 @@ sign_in_with = Sign In With sign_out = Sign Out sign_up = Register link_account = Link Account -link_account_signin_or_signup = Sign in with existing credentials to link your existing account to this account. Or register a new one. register = Register website = Website version = Version @@ -230,6 +229,12 @@ twofa_passcode_incorrect = Your passcode is incorrect. If you misplaced your dev twofa_scratch_token_incorrect = Your scratch code is incorrect. login_userpass = Sign In login_openid = OpenID +oauth_signup_tab = Register New Account +oauth_signup_title = Add Email and Password (for Account Recovery) +oauth_signup_submit = Complete Account +oauth_signin_tab = Link to Existing Account +oauth_signin_title = Sign In to Authorize Linked Account +oauth_signin_submit = Link Account openid_connect_submit = Connect openid_connect_title = Connect to an existing account openid_connect_desc = The chosen OpenID URI is unknown. Associate it with a new account here. diff --git a/routers/user/auth.go b/routers/user/auth.go index a4a0ee3e6..25aa437ef 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -664,8 +664,30 @@ func LinkAccount(ctx *context.Context) { return } - ctx.Data["user_name"] = gothUser.(goth.User).NickName - ctx.Data["email"] = gothUser.(goth.User).Email + uname := gothUser.(goth.User).NickName + email := gothUser.(goth.User).Email + ctx.Data["user_name"] = uname + ctx.Data["email"] = email + + if len(email) != 0 { + u, err := models.GetUserByEmail(email) + if err != nil && !models.IsErrUserNotExist(err) { + ctx.ServerError("UserSignIn", err) + return + } + if u != nil { + ctx.Data["user_exists"] = true + } + } else if len(uname) != 0 { + u, err := models.GetUserByName(uname) + if err != nil && !models.IsErrUserNotExist(err) { + ctx.ServerError("UserSignIn", err) + return + } + if u != nil { + ctx.Data["user_exists"] = true + } + } ctx.HTML(200, tplLinkAccount) } diff --git a/templates/user/auth/link_account.tmpl b/templates/user/auth/link_account.tmpl index 73aafd6fe..339ca855d 100644 --- a/templates/user/auth/link_account.tmpl +++ b/templates/user/auth/link_account.tmpl @@ -1,15 +1,33 @@ {{template "base/head" .}} + -
-{{template "user/auth/signin_inner" .}} -
-{{template "user/auth/signup_inner" .}} + {{template "base/footer" .}} diff --git a/templates/user/auth/signin_inner.tmpl b/templates/user/auth/signin_inner.tmpl index 019bda570..bf1cc055f 100644 --- a/templates/user/auth/signin_inner.tmpl +++ b/templates/user/auth/signin_inner.tmpl @@ -2,7 +2,11 @@ {{template "base/alert" .}} {{end}}

- {{.i18n.Tr "auth.login_userpass"}} + {{if .LinkAccountMode}} + {{.i18n.Tr "auth.oauth_signin_title"}} + {{else}} + {{.i18n.Tr "auth.login_userpass"}} + {{end}}

@@ -27,7 +31,13 @@
- + {{.i18n.Tr "auth.forgot_password"}}
diff --git a/templates/user/auth/signup_inner.tmpl b/templates/user/auth/signup_inner.tmpl index cd969276b..25b50dad8 100644 --- a/templates/user/auth/signup_inner.tmpl +++ b/templates/user/auth/signup_inner.tmpl @@ -4,7 +4,11 @@ {{.CsrfTokenHtml}}

- {{.i18n.Tr "sign_up"}} + {{if .LinkAccountMode}} + {{.i18n.Tr "auth.oauth_signup_title"}} + {{else}} + {{.i18n.Tr "sign_up"}} + {{end}}

{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister)}} @@ -47,7 +51,13 @@
- +
{{if not .LinkAccountMode}}