summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorAJ ONeal <coolaj86@gmail.com>2018-10-28 16:46:16 -0600
committertechknowlogick <hello@techknowlogick.com>2018-10-28 18:46:16 -0400
commitb8451190d85af255a94b02cdfdd6d375015b3864 (patch)
tree19430b0cb6609dbf7904625269aa47a2b8e344b5 /routers/user
parenta2ee2a3c67304920a968c1c852e43b3dc2d7c3e7 (diff)
downloadgitea-b8451190d85af255a94b02cdfdd6d375015b3864.tar.gz
gitea-b8451190d85af255a94b02cdfdd6d375015b3864.zip
UX of link account (Step 1) (#5006)
* Show either sign up OR sign in * disambiguate fresh start from adding recovery options * use tabs to switch between account link flows * add active to tab body as well * changes as per discussion * handle specific error; fix missing err typo
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/auth.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go
index a4a0ee3e6a..25aa437efd 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)
}