Backport #18045 The current code unfortunately requires that `action` be a reserved repository name as it prevents posts to change the settings for action repositories. However, we can simply change action handler to work on POST /{username} instead. Fix #18037 Signed-off-by: Andrew Thornton <art27@cantab.net>release/v1.15
parent
76e1c130fb
commit
a818a48c76
|
@ -321,7 +321,7 @@ func Action(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch ctx.Params(":action") {
|
switch ctx.Query("action") {
|
||||||
case "follow":
|
case "follow":
|
||||||
err = models.FollowUser(ctx.User.ID, u.ID)
|
err = models.FollowUser(ctx.User.ID, u.ID)
|
||||||
case "unfollow":
|
case "unfollow":
|
||||||
|
@ -329,7 +329,7 @@ func Action(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Params(":action")), err)
|
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Query("action")), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -461,9 +461,7 @@ func RegisterRoutes(m *web.Route) {
|
||||||
m.Get("/attachments/{uuid}", repo.GetAttachment)
|
m.Get("/attachments/{uuid}", repo.GetAttachment)
|
||||||
}, ignSignIn)
|
}, ignSignIn)
|
||||||
|
|
||||||
m.Group("/{username}", func() {
|
m.Post("/{username}", reqSignIn, user.Action)
|
||||||
m.Post("/action/{action}", user.Action)
|
|
||||||
}, reqSignIn)
|
|
||||||
|
|
||||||
if !setting.IsProd() {
|
if !setting.IsProd() {
|
||||||
m.Get("/template/*", dev.TemplatePreview)
|
m.Get("/template/*", dev.TemplatePreview)
|
||||||
|
|
|
@ -66,12 +66,12 @@
|
||||||
{{if and .IsSigned (ne .SignedUserName .Owner.Name)}}
|
{{if and .IsSigned (ne .SignedUserName .Owner.Name)}}
|
||||||
<li class="follow">
|
<li class="follow">
|
||||||
{{if .SignedUser.IsFollowing .Owner.ID}}
|
{{if .SignedUser.IsFollowing .Owner.ID}}
|
||||||
<form method="post" action="{{.Link}}/action/unfollow?redirect_to={{$.Link}}">
|
<form method="post" action="{{.Link}}?action=unfollow&redirect_to={{$.Link}}">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<button type="submit" class="ui basic red button">{{svg "octicon-person"}} {{.i18n.Tr "user.unfollow"}}</button>
|
<button type="submit" class="ui basic red button">{{svg "octicon-person"}} {{.i18n.Tr "user.unfollow"}}</button>
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form method="post" action="{{.Link}}/action/follow?redirect_to={{$.Link}}">
|
<form method="post" action="{{.Link}}?action=follow&redirect_to={{$.Link}}">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<button type="submit" class="ui basic green button">{{svg "octicon-person"}} {{.i18n.Tr "user.follow"}}</button>
|
<button type="submit" class="ui basic green button">{{svg "octicon-person"}} {{.i18n.Tr "user.follow"}}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue