From 15f5d8e794b7ec8b7203fe8ee4c0068cce0b1abf Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 7 Mar 2017 11:47:56 +0100 Subject: [PATCH] Reduce conditionals in signin/signup inner forms by always using SignInLink and SignUpLink in the form action --- routers/user/auth.go | 13 +++++++++---- templates/user/auth/signin_inner.tmpl | 2 +- templates/user/auth/signup_inner.tmpl | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/routers/user/auth.go b/routers/user/auth.go index 4827f38b524..ba20dc7d42f 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -120,6 +120,7 @@ func SignIn(ctx *context.Context) { } ctx.Data["OAuth2Providers"] = oauth2Providers ctx.Data["Title"] = ctx.Tr("sign_in") + ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login" ctx.Data["PageIsSignIn"] = true ctx.Data["PageIsLogin"] = true @@ -128,16 +129,16 @@ func SignIn(ctx *context.Context) { // SignInPost response for sign in request func SignInPost(ctx *context.Context, form auth.SignInForm) { - ctx.Data["Title"] = ctx.Tr("sign_in") - ctx.Data["PageIsSignIn"] = true - ctx.Data["PageIsLogin"] = true - oauth2Providers, err := models.GetActiveOAuth2Providers() if err != nil { ctx.Handle(500, "UserSignIn", err) return } ctx.Data["OAuth2Providers"] = oauth2Providers + ctx.Data["Title"] = ctx.Tr("sign_in") + ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login" + ctx.Data["PageIsSignIn"] = true + ctx.Data["PageIsLogin"] = true if ctx.HasError() { ctx.HTML(200, tplSignIn) @@ -700,6 +701,8 @@ func SignOut(ctx *context.Context) { func SignUp(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("sign_up") + ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up" + ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration @@ -711,6 +714,8 @@ func SignUp(ctx *context.Context) { func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterForm) { ctx.Data["Title"] = ctx.Tr("sign_up") + ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up" + ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha if setting.Service.DisableRegistration { diff --git a/templates/user/auth/signin_inner.tmpl b/templates/user/auth/signin_inner.tmpl index c8df0870b70..c89f2f358d5 100644 --- a/templates/user/auth/signin_inner.tmpl +++ b/templates/user/auth/signin_inner.tmpl @@ -5,7 +5,7 @@ {{.i18n.Tr "auth.login_userpass"}}
-
+ {{.CsrfTokenHtml}}
diff --git a/templates/user/auth/signup_inner.tmpl b/templates/user/auth/signup_inner.tmpl index 869f3d5342c..52386f6dcf6 100644 --- a/templates/user/auth/signup_inner.tmpl +++ b/templates/user/auth/signup_inner.tmpl @@ -1,7 +1,7 @@
- + {{.CsrfTokenHtml}}

{{.i18n.Tr "sign_up"}} @@ -56,4 +56,4 @@

-
\ No newline at end of file +