-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix login redirection links #17451
Fix login redirection links #17451
Conversation
And if the login router could check if the redirect_to is itself is better. |
@@ -192,7 +192,7 @@ | |||
{{svg "octicon-person"}} {{.i18n.Tr "register"}} | |||
</a> | |||
{{end}} | |||
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login?redirect_to={{.CurrentURL}}"> | |||
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login{{if not .PageIsSignIn}}?redirect_to={{.CurrentURL}}{{end}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider href="{{if not .PageIsSignIn}}{{AppSubUrl}}/user/login?redirect_to={{end}}{{.CurrentURL}}"
to keep the original link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds very cool, but it doesn't work:
package main
import (
"html/template"
"log"
"os"
)
func main() {
tplStr := `
<a href="{{.url}}">
<a href="?redirect={{.url}}">
<a href="{{if true}}?{{end}}redirect={{.url}}">
<a href="{{if not true}}?{{end}}redirect={{.url}}">
`
tpl := template.Must(template.New("tplName").Parse(tplStr))
err := tpl.Execute(os.Stdout, map[string]interface{}{"url":"/p?a=1&b=2#h", "true": true})
log.Printf("err = %v", err)
}
error: 2021/10/28 17:23:38 err = html/template:tplName:4:40: {{.url}} appears in an ambiguous context within a URL
Codecov Report
@@ Coverage Diff @@
## main #17451 +/- ##
=======================================
Coverage ? 45.48%
=======================================
Files ? 791
Lines ? 88697
Branches ? 0
=======================================
Hits ? 40341
Misses ? 41840
Partials ? 6516 Continue to review full report at Codecov.
|
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Doesn't add the
redirect_to
argument if page is login.fixes #17421 fixes #17444