mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-27 20:49:33 +08:00
Simplify, fix logic error
This commit is contained in:
parent
a352455b81
commit
754ce8ee61
@ -236,18 +236,16 @@ func PublicizeMember(ctx *context.APIContext) {
|
|||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
allowed := userToPublicize.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin
|
if userToPublicize.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin {
|
||||||
if !allowed {
|
|
||||||
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
|
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "ChangeOrgUserStatus", err)
|
ctx.Error(http.StatusInternalServerError, "ChangeOrgUserStatus", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
allowed = isOwner
|
if !isOwner {
|
||||||
}
|
ctx.Error(http.StatusForbidden, "", "Cannot publicize another member")
|
||||||
if !allowed {
|
return
|
||||||
ctx.Error(http.StatusForbidden, "", "Cannot publicize another member")
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
err := organization.ChangeOrgUserStatus(ctx, ctx.Org.Organization.ID, userToPublicize.ID, true)
|
err := organization.ChangeOrgUserStatus(ctx, ctx.Org.Organization.ID, userToPublicize.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -287,18 +285,16 @@ func ConcealMember(ctx *context.APIContext) {
|
|||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
allowed := userToConceal.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin
|
if userToConceal.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin {
|
||||||
if !allowed {
|
|
||||||
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
|
isOwner, err := ctx.Org.Organization.IsOwnedBy(ctx, ctx.Doer.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "ChangeOrgUserStatus", err)
|
ctx.Error(http.StatusInternalServerError, "ChangeOrgUserStatus", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
allowed = isOwner
|
if !isOwner {
|
||||||
}
|
ctx.Error(http.StatusForbidden, "", "Cannot conceal another member")
|
||||||
if !allowed {
|
return
|
||||||
ctx.Error(http.StatusForbidden, "", "Cannot conceal another member")
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
err := organization.ChangeOrgUserStatus(ctx, ctx.Org.Organization.ID, userToConceal.ID, false)
|
err := organization.ChangeOrgUserStatus(ctx, ctx.Org.Organization.ID, userToConceal.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user