-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fix org admin can not access org project unit #25691
Conversation
models/migrations/v1_21/v268.go
Outdated
AccessModeRead = 1 | ||
// AccessModeAdmin admin access | ||
AccessModeAdmin = 3 | ||
|
||
// Unit Type | ||
TypeInvalid UnitType = iota // 0 invalid | ||
TypeCode // 1 code | ||
TypeIssues // 2 issues | ||
TypePullRequests // 3 PRs | ||
TypeReleases // 4 Releases | ||
TypeWiki // 5 Wiki | ||
TypeExternalWiki // 6 ExternalWiki | ||
TypeExternalTracker // 7 ExternalTracker | ||
TypeProjects // 8 Kanban board | ||
TypePackages // 9 Packages | ||
TypeActions // 10 Actions | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
Need someone to review. |
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Need reviewers. |
models/migrations/v1_22/v285.go
Outdated
|
||
// find all admin teams | ||
teams := make([]*Team, 0) | ||
err := sess.Where("team.authorize = ?", AccessModeAdmin).Find(&teams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may consume much memory for a big instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
if existingUnitTypes.Contains(u) { | ||
sess.Cols("access_mode").Update(newTeamUnit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returned error haven't been handlered.
if existingUnitTypes.Contains(u) { | ||
sess.Cols("access_mode").Update(newTeamUnit) | ||
} else { | ||
sess.Insert(newTeamUnit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above.
} | ||
} | ||
|
||
return sess.Commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to detect whether there are still records haven't been committed. Some database will fail if submit a zero change commit.
@lunny |
Fix #25670
We should backport the logic fix to 1.19 and 1.20
DB migration is only for 1.21