Skip to content

Commit 2842f6c

Browse files
Include query in sign in redirect (#11579)
* Include query in sign in redirect Include query string in ctx.Data["SignInLink"] so people are redirected to the right page after singing in. Fixes case of: Visit: https://try.gitea.io/mrsdizzie/testcase/issues?q=&type=all&sort=&state=open&labels=7071&milestone=0&assignee=0 Sign in, then redirected to: https://try.gitea.io/mrsdizzie/testcase/issues Create a new "SignInLink" instead of updating the existing "Link" because too many places in the code assume "Link" won't have a query * Apply suggestions from code review Co-authored-by: techknowlogick <[email protected]>
1 parent 3affe95 commit 2842f6c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func Contexter() macaron.Handler {
242242
}
243243
ctx.Data["Language"] = ctx.Locale.Language()
244244
c.Data["Link"] = ctx.Link
245+
ctx.Data["CurrentURL"] = setting.AppSubURL + c.Req.URL.RequestURI()
245246
ctx.Data["PageStartTime"] = time.Now()
246247
// Quick responses appropriate go-get meta with status 200
247248
// regardless of if user have access to the repository,

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
{{svg "octicon-person" 16}} {{.i18n.Tr "register"}}
155155
</a>
156156
{{end}}
157-
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login?redirect_to={{.Link}}">
157+
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login?redirect_to={{.CurrentURL}}">
158158
{{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}}
159159
</a>
160160
</div><!-- end anonymous right menu -->

0 commit comments

Comments
 (0)