Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsAdmin in Organization #28838

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Jan 18, 2024

Add IsAdmin in Organization and IsOrganizationAdmin in context data.
Then we can easily check whether doer is an organization admin.

ps: a previous PR for #28837

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 18, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 18, 2024
@@ -145,6 +148,11 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
ctx.ServerError("IsOrgMember", err)
return
}
ctx.Org.IsAdmin, err = org.IsOrgAdmin(ctx, ctx.Doer.ID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we only execute this check if the user is actually a member?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some changes in 84bab56

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 18, 2024
@delvh delvh added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Jan 18, 2024
IsMember bool // Is member of the org
IsAdmin bool // Is admin of the org
IsTeamMember bool // Is member of team, only used in urls which has team param
IsTeamAdmin bool // Is in owner team or team that has admin permission level, only used in urls which has team param
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the different between IsTeamAdmin and IsAdmin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤨 Sounds like they are the same.
But if that is indeed the case, I still support renaming IsTeamAdmin to IsAdmin or IsOrgAdmin (if we are concerned about confusion with site admins) as IsTeamAdmin reads as if the user only has admin rights within the team instead of the whole org.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, ctx.Org.IsTeamAdmin is only used in OrgAssignment function for checking requireTeamAdmin.
image

Then, ctx.Data["IsTeamAdmin"] is empty when the URL doesn't have team param.
So if we want to detect whether doer is the admin in these pages.
So I think we need ctx.Data["IsOrganizationAdmin"], and ctx.Org.IsTeamAdmin can be removed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants