0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-22 17:24:41 +02:00
This commit is contained in:
Excellencedev 2026-01-16 17:38:12 +01:00
parent 01a328bed0
commit 5067f1dbfa
2 changed files with 6 additions and 5 deletions

View File

@ -150,8 +150,11 @@ func UpdateTokenPermissions(ctx *context.Context) {
// If checked, it means we WANT to override (opt-out of following)
actionsCfg.OverrideOrgConfig = ctx.FormBool("override_org_config")
// Update permission mode (only if overriding org config)
if actionsCfg.OverrideOrgConfig {
// Update permission mode (only if overriding org config OR not in an org)
isOrg := ctx.Repo.Repository.Owner.IsOrganization()
shouldUpdate := !isOrg || actionsCfg.OverrideOrgConfig
if shouldUpdate {
permissionMode := repo_model.ActionsTokenPermissionMode(ctx.FormString("token_permission_mode"))
if permissionMode == repo_model.ActionsTokenPermissionModeRestricted ||
permissionMode == repo_model.ActionsTokenPermissionModePermissive ||
@ -165,7 +168,7 @@ func UpdateTokenPermissions(ctx *context.Context) {
}
// Update Maximum Permissions (radio buttons: none/read/write)
if actionsCfg.OverrideOrgConfig && actionsCfg.TokenPermissionMode == repo_model.ActionsTokenPermissionModeCustom {
if shouldUpdate && actionsCfg.TokenPermissionMode == repo_model.ActionsTokenPermissionModeCustom {
parseMaxPerm := func(name string) perm.AccessMode {
value := ctx.FormString("max_" + name)
switch value {

View File

@ -280,7 +280,6 @@ func TestActionsTokenPermissionsClamping(t *testing.T) {
// Set Clamping Config: Custom Mode (Default=Max), Max Code = Read
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings/actions/general/token_permissions", repo.OwnerName, repo.Name), map[string]string{
"override_org_config": "true",
"token_permission_mode": "custom",
"max_code": "read",
})
@ -346,7 +345,6 @@ func TestActionsTokenPackagePermission(t *testing.T) {
// Set Config: Custom Mode, Max Packages = Write, Max Code = Read
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings/actions/general/token_permissions", repo.OwnerName, repo.Name), map[string]string{
"override_org_config": "true",
"token_permission_mode": "custom",
"max_packages": "write",
"max_code": "read", // Ensure repo read access if needed