forked from forgejo/forgejo
Fix ignored errors when checking if organization, team member (#3177)
This commit is contained in:
parent
529482135c
commit
515cdaa85d
16 changed files with 281 additions and 144 deletions
|
@ -74,10 +74,20 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
|||
}
|
||||
|
||||
// Check ownership of organization.
|
||||
if !org.IsOrganization() || !(ctx.User.IsAdmin || org.IsOwnedBy(ctx.User.ID)) {
|
||||
if !org.IsOrganization() {
|
||||
ctx.Error(403)
|
||||
return nil
|
||||
}
|
||||
if !ctx.User.IsAdmin {
|
||||
isOwner, err := org.IsOwnedBy(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "IsOwnedBy", err)
|
||||
return nil
|
||||
} else if !isOwner {
|
||||
ctx.Error(403)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return org
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue