@@ -94,7 +94,7 @@ func (g *Group) LoadSubgroups(ctx context.Context, recursive bool) error {
9494}
9595
9696func (g * Group ) LoadAccessibleSubgroups (ctx context.Context , recursive bool , doer * user_model.User ) error {
97- return g .doLoadSubgroups (ctx , recursive , AccessibleGroupCondition (doer , unit .TypeInvalid ), 0 )
97+ return g .doLoadSubgroups (ctx , recursive , AccessibleGroupCondition (doer , unit .TypeInvalid , perm . AccessModeRead ), 0 )
9898}
9999
100100func (g * Group ) LoadAttributes (ctx context.Context ) error {
@@ -129,13 +129,12 @@ func (g *Group) LoadOwner(ctx context.Context) error {
129129 return err
130130}
131131
132- func (g * Group ) CanAccess (ctx context.Context , userID int64 ) (bool , error ) {
133- return g .CanAccessAtLevel (ctx , userID , perm .AccessModeRead )
132+ func (g * Group ) CanAccess (ctx context.Context , user * user_model. User ) (bool , error ) {
133+ return g .CanAccessAtLevel (ctx , user , perm .AccessModeRead )
134134}
135135
136- func (g * Group ) CanAccessAtLevel (ctx context.Context , userID int64 , level perm.AccessMode ) (bool , error ) {
137- return db .GetEngine (ctx ).
138- Where (UserOrgTeamPermCond ("id" , userID , level )).Table ("repo_group" ).Exist ()
136+ func (g * Group ) CanAccessAtLevel (ctx context.Context , user * user_model.User , level perm.AccessMode ) (bool , error ) {
137+ return db .GetEngine (ctx ).Where (AccessibleGroupCondition (user , unit .TypeInvalid , level ).And (builder.Eq {"`repo_group`.id" : g .ID })).Exist (& Group {})
139138}
140139
141140func (g * Group ) IsOwnedBy (ctx context.Context , userID int64 ) (bool , error ) {
@@ -337,9 +336,10 @@ func UpdateGroup(ctx context.Context, group *Group) error {
337336func MoveGroup (ctx context.Context , group * Group , newParent int64 , newSortOrder int ) error {
338337 sess := db .GetEngine (ctx )
339338 ng , err := GetGroupByID (ctx , newParent )
340- if ! IsErrGroupNotExist (err ) {
339+ if err != nil && ! IsErrGroupNotExist (err ) {
341340 return err
342341 }
342+
343343 if ng != nil {
344344 if ng .OwnerID != group .OwnerID {
345345 return fmt .Errorf ("group[%d]'s ownerID is not equal to new parent group[%d]'s owner ID" , group .ID , ng .ID )
0 commit comments