summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routers/web/user/profile.go4
-rw-r--r--routers/web/web.go4
-rw-r--r--templates/user/profile.tmpl4
3 files changed, 5 insertions, 7 deletions
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 77b357c222..40fc44ed14 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -363,7 +363,7 @@ func Action(ctx *context.Context) {
}
var err error
- switch ctx.Params(":action") {
+ switch ctx.FormString("action") {
case "follow":
err = user_model.FollowUser(ctx.User.ID, u.ID)
case "unfollow":
@@ -371,7 +371,7 @@ func Action(ctx *context.Context) {
}
if err != nil {
- ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Params(":action")), err)
+ ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.FormString("action")), err)
return
}
// FIXME: We should check this URL and make sure that it's a valid Gitea URL
diff --git a/routers/web/web.go b/routers/web/web.go
index 6ede410e3e..41c4e122fb 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -484,9 +484,7 @@ func RegisterRoutes(m *web.Route) {
m.Get("/attachments/{uuid}", repo.GetAttachment)
}, ignSignIn)
- m.Group("/{username}", func() {
- m.Post("/action/{action}", user.Action)
- }, reqSignIn)
+ m.Post("/{username}", reqSignIn, user.Action)
if !setting.IsProd {
m.Get("/template/*", dev.TemplatePreview)
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 3bb15449a2..e0a6b39121 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -66,12 +66,12 @@
{{if and .IsSigned (ne .SignedUserName .Owner.Name)}}
<li class="follow">
{{if $.IsFollowing}}
- <form method="post" action="{{.Link}}/action/unfollow?redirect_to={{$.Link}}">
+ <form method="post" action="{{.Link}}?action=unfollow&redirect_to={{$.Link}}">
{{$.CsrfTokenHtml}}
<button type="submit" class="ui basic red button">{{svg "octicon-person"}} {{.i18n.Tr "user.unfollow"}}</button>
</form>
{{else}}
- <form method="post" action="{{.Link}}/action/follow?redirect_to={{$.Link}}">
+ <form method="post" action="{{.Link}}?action=follow&redirect_to={{$.Link}}">
{{$.CsrfTokenHtml}}
<button type="submit" class="ui basic green button">{{svg "octicon-person"}} {{.i18n.Tr "user.follow"}}</button>
</form>