1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-09-15 18:56:59 +00:00

MembersAction handler changes

This commit is contained in:
Daksh Bhayana 2025-06-16 22:38:30 +05:30
parent b369bc8a57
commit 3c061edafd
2 changed files with 6 additions and 13 deletions

View file

@ -79,12 +79,10 @@ func Members(ctx *context.Context) {
func MembersAction(ctx *context.Context) {
uid := ctx.FormInt64("uid")
if uid == 0 {
ctx.Redirect(ctx.Org.OrgLink + "/members")
ctx.Redirect("/user/settings/organization")
return
}
redirectURL := ctx.FormString("redirect")
org := ctx.Org.Organization
var err error
switch ctx.Params(":action") {
@ -108,7 +106,7 @@ func MembersAction(ctx *context.Context) {
err = models.RemoveOrgUser(ctx, org.ID, uid)
if organization.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.JSONRedirect(ctx.Org.OrgLink + "/members")
ctx.JSONRedirect("/user/settings/organization")
return
}
case "leave":
@ -120,7 +118,7 @@ func MembersAction(ctx *context.Context) {
})
} else if organization.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.JSONRedirect(ctx.Org.OrgLink + "/members")
ctx.JSONRedirect("/user/settings/organization")
} else {
log.Error("RemoveOrgUser(%d,%d): %v", org.ID, ctx.Doer.ID, err)
}
@ -136,12 +134,7 @@ func MembersAction(ctx *context.Context) {
return
}
if redirectURL != "" {
ctx.JSONRedirect(redirectURL)
return
}
redirect := ctx.Org.OrgLink + "/members"
redirect := "/user/settings/organization"
if ctx.Params(":action") == "leave" {
redirect = setting.AppSubURL + "/"
}

View file

@ -25,9 +25,9 @@
<div class="flex-item-trailing">
{{$isPublic := index $.OrgsIsPublicMember .ID}}
{{if $isPublic}}
<a class="ui tiny button link-action" href data-url="{{.OrganisationLink}}/members/action/private?uid={{$.SignedUser.ID}}&redirect=/user/settings/organization">{{svg "octicon-eye-closed" 12 "icon"}}{{ctx.Locale.Tr "org.members.public_helper"}}</a>
<a class="ui tiny button link-action" href data-url="{{.OrganisationLink}}/members/action/private?uid={{$.SignedUser.ID}}">{{svg "octicon-eye-closed" 12 "icon"}}{{ctx.Locale.Tr "org.members.public_helper"}}</a>
{{else}}
<a class="ui tiny button link-action" href data-url="{{.OrganisationLink}}/members/action/public?uid={{$.SignedUser.ID}}&redirect=/user/settings/organization">{{svg "octicon-eye" 12 "icon"}}{{ctx.Locale.Tr "org.members.private_helper"}}</a>
<a class="ui tiny button link-action" href data-url="{{.OrganisationLink}}/members/action/public?uid={{$.SignedUser.ID}}">{{svg "octicon-eye" 12 "icon"}}{{ctx.Locale.Tr "org.members.private_helper"}}</a>
{{end}}
<form>
{{$.CsrfTokenHtml}}