Skip to content

Commit 600bb54

Browse files
guillep2kzeripath
andauthored
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 <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
1 parent 5331af1 commit 600bb54

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

modules/context/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func Toggle(options *ToggleOptions) macaron.Handler {
4949
if ctx.Req.URL.Path != "/user/settings/change_password" {
5050
ctx.Data["Title"] = ctx.Tr("auth.must_change_password")
5151
ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/change_password"
52-
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
52+
if ctx.Req.URL.Path != "/user/events" {
53+
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL)
54+
}
5355
ctx.Redirect(setting.AppSubURL + "/user/settings/change_password")
5456
return
5557
}

routers/user/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,7 @@ func ResetPasswdPost(ctx *context.Context) {
14891489
func MustChangePassword(ctx *context.Context) {
14901490
ctx.Data["Title"] = ctx.Tr("auth.must_change_password")
14911491
ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password"
1492+
ctx.Data["MustChangePassword"] = true
14921493
ctx.HTML(200, tplMustChangePassword)
14931494
}
14941495

templates/base/head_navbar.tmpl

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
</div>
99
</div>
1010

11-
{{if .IsSigned}}
11+
{{if and .IsSigned .MustChangePassword}}
12+
{{/* No links */}}
13+
{{else if .IsSigned}}
1214
<a class="item {{if .PageIsDashboard}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "dashboard"}}</a>
1315
{{if not .UnitIssuesGlobalDisabled}}
1416
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a>
@@ -40,7 +42,30 @@
4042
</div>
4143
*/}}
4244

43-
{{if .IsSigned}}
45+
46+
{{if and .IsSigned .MustChangePassword}}
47+
<div class="right stackable menu">
48+
<div class="ui dropdown jump item poping up" tabindex="-1" data-content="{{.i18n.Tr "user_profile_and_more"}}" data-variation="tiny inverted">
49+
<span class="text">
50+
<img class="ui tiny avatar image" width="24" height="24" src="{{.SignedUser.RelAvatarLink}}">
51+
<span class="sr-only">{{.i18n.Tr "user_profile_and_more"}}</span>
52+
<span class="mobile-only">{{.SignedUser.Name}}</span>
53+
<span class="fitted not-mobile" tabindex="-1">{{svg "octicon-triangle-down" 16}}</span>
54+
</span>
55+
<div class="menu user-menu" tabindex="-1">
56+
<div class="ui header">
57+
{{.i18n.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
58+
</div>
59+
60+
<div class="divider"></div>
61+
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
62+
{{svg "octicon-sign-out" 16}}
63+
{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
64+
</a>
65+
</div><!-- end content avatar menu -->
66+
</div><!-- end dropdown avatar menu -->
67+
</div>
68+
{{else if .IsSigned}}
4469
<div class="right stackable menu">
4570
<a href="{{AppSubUrl}}/notifications" class="item poping up" data-content='{{.i18n.Tr "notifications"}}' data-variation="tiny inverted">
4671
<span class="text">
@@ -121,9 +146,7 @@
121146
</div><!-- end content avatar menu -->
122147
</div><!-- end dropdown avatar menu -->
123148
</div><!-- end signed user right menu -->
124-
125149
{{else}}
126-
127150
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a>
128151
<div class="right stackable menu">
129152
{{if .ShowRegistrationButton}}
@@ -135,6 +158,5 @@
135158
{{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}}
136159
</a>
137160
</div><!-- end anonymous right menu -->
138-
139161
{{end}}
140162
</div>

0 commit comments

Comments
 (0)