From fa7fc43a13c0d8c01d9ccbcbbbd92417b2d54b44 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 3 Oct 2018 05:07:49 +0000 Subject: [PATCH] Show either sign up OR sign in --- routers/user/auth.go | 19 +++++++++++++++++-- templates/user/auth/link_account.tmpl | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/routers/user/auth.go b/routers/user/auth.go index 706dc6c14..781813063 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -655,8 +655,23 @@ 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 "" != uname { + u, _ := models.GetUserByName(uname) + if u != nil { + ctx.Data["user_name_exists"] = "true" + } + } + if "" != email { + u, _ := models.GetUserByEmail(email) + if u != nil { + ctx.Data["email_exists"] = "true" + } + } ctx.HTML(200, tplLinkAccount) } diff --git a/templates/user/auth/link_account.tmpl b/templates/user/auth/link_account.tmpl index 73aafd6fe..098d904d2 100644 --- a/templates/user/auth/link_account.tmpl +++ b/templates/user/auth/link_account.tmpl @@ -8,8 +8,13 @@ + +{{if or .user_name_exists .email_exists}}
{{template "user/auth/signin_inner" .}}
+{{else}} {{template "user/auth/signup_inner" .}} +{{end}} + {{template "base/footer" .}}