Skip to content

Commit 9e6e716

Browse files
committed
fix follow/unfollow redirect
1 parent f2bb305 commit 9e6e716

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

routers/web/user/profile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ func Action(ctx *context.Context) {
287287
}
288288

289289
if err != nil {
290-
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.FormString("action")), err)
290+
log.Error("Failed to apply action %q: %v", ctx.FormString("action"), err)
291+
ctx.JSONError(fmt.Sprintf("Action %q failed", ctx.FormString("action")))
291292
return
292293
}
293-
// FIXME: We should check this URL and make sure that it's a valid Gitea URL
294-
ctx.RedirectToFirst(ctx.FormString("redirect_to"), ctx.ContextUser.HomeLink())
294+
ctx.JSONOK()
295295
}

templates/org/home.tmpl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020
</div>
2121
</div>
2222
<div class="right menu">
23-
<form method="post" action="{{.Link}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}&redirect_to={{$.Link}}">
24-
{{$.CsrfTokenHtml}}
25-
<button type="submit" class="ui basic button gt-mr-0">
26-
{{if $.IsFollowing}}
27-
{{.locale.Tr "user.unfollow"}}
28-
{{else}}
29-
{{.locale.Tr "user.follow"}}
30-
{{end}}
31-
</button>
32-
</form>
23+
<button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
24+
{{if $.IsFollowing}}
25+
{{.locale.Tr "user.unfollow"}}
26+
{{else}}
27+
{{.locale.Tr "user.follow"}}
28+
{{end}}
29+
</button>
3330
</div>
3431
</div>
3532

templates/shared/user/profile_big_avatar.tmpl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@
9999
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
100100
<li class="follow">
101101
{{if $.IsFollowing}}
102-
<form method="post" action="{{.ContextUser.HomeLink}}?action=unfollow&redirect_to={{$.Link}}">
103-
{{$.CsrfTokenHtml}}
104-
<button type="submit" class="ui basic red button">{{svg "octicon-person"}} {{.locale.Tr "user.unfollow"}}</button>
105-
</form>
102+
<button class="ui basic red button link-action" data-url="{{.ContextUser.HomeLink}}?action=unfollow">
103+
{{svg "octicon-person"}} {{.locale.Tr "user.unfollow"}}
104+
</button>
106105
{{else}}
107-
<form method="post" action="{{.ContextUser.HomeLink}}?action=follow&redirect_to={{$.Link}}">
108-
{{$.CsrfTokenHtml}}
109-
<button type="submit" class="ui basic green button">{{svg "octicon-person"}} {{.locale.Tr "user.follow"}}</button>
110-
</form>
106+
<button class="ui basic green button link-action" data-url="{{.ContextUser.HomeLink}}?action=follow">
107+
{{svg "octicon-person"}} {{.locale.Tr "user.follow"}}
108+
</button>
111109
{{end}}
112110
</li>
113111
{{end}}

0 commit comments

Comments
 (0)