From 600bb545f3fb016d6833d0be92e1af7153f30454 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Wed, 27 May 2020 04:08:14 -0300 Subject: [PATCH] When must change password only show Signout (#11600) (#11637) When "Must Change Password" simplify the navbar header to only show the signout button as all other links will redirect back. This prevents the notifications icon from showing preventing initialization of the event-source and hence preventing redirect_to being set, however in addition do not set the redirect_to cookie if we are looking at the /user/events page. Fix #11554 Signed-off-by: Andrew Thornton Co-authored-by: zeripath --- modules/context/auth.go | 4 +++- routers/user/auth.go | 1 + templates/base/head_navbar.tmpl | 32 +++++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/context/auth.go b/modules/context/auth.go index 7410db75a..86922aae5 100644 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -49,7 +49,9 @@ func Toggle(options *ToggleOptions) macaron.Handler { if ctx.Req.URL.Path != "/user/settings/change_password" { ctx.Data["Title"] = ctx.Tr("auth.must_change_password") ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/change_password" - ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + if ctx.Req.URL.Path != "/user/events" { + ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + } ctx.Redirect(setting.AppSubURL + "/user/settings/change_password") return } diff --git a/routers/user/auth.go b/routers/user/auth.go index e1a885480..a253e6cdb 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1489,6 +1489,7 @@ func ResetPasswdPost(ctx *context.Context) { func MustChangePassword(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.must_change_password") ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password" + ctx.Data["MustChangePassword"] = true ctx.HTML(200, tplMustChangePassword) } diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index cedf29e2e..393671d3a 100644 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -8,7 +8,9 @@ - {{if .IsSigned}} + {{if and .IsSigned .MustChangePassword}} + {{/* No links */}} + {{else if .IsSigned}} {{.i18n.Tr "dashboard"}} {{if not .UnitIssuesGlobalDisabled}} {{.i18n.Tr "issues"}} @@ -40,7 +42,30 @@ */}} - {{if .IsSigned}} + + {{if and .IsSigned .MustChangePassword}} + + {{else if .IsSigned}} - {{else}} - {{.i18n.Tr "help"}} - {{end}}