Skip to content

Commit cdf3dd6

Browse files
authored
fix(server): Cannot access a workspace (#1748)
1 parent 343322e commit cdf3dd6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

server/internal/infrastructure/mongo/project.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (r *Project) Filtered(f repo.WorkspaceFilter) repo.Project {
5656
func (r *Project) FindByID(ctx context.Context, id id.ProjectID) (*project.Project, error) {
5757
prj, err := r.findOne(ctx, bson.M{
5858
"id": id.String(),
59-
}, true)
59+
}, false)
6060

6161
if err != nil {
6262
if err == mongo.ErrNoDocuments {
@@ -72,9 +72,19 @@ func (r *Project) FindByScene(ctx context.Context, id id.SceneID) (*project.Proj
7272
if !r.s.CanRead(id) {
7373
return nil, nil
7474
}
75-
return r.findOne(ctx, bson.M{
75+
76+
prj, err := r.findOne(ctx, bson.M{
7677
"scene": id.String(),
77-
}, true)
78+
}, false)
79+
80+
if err != nil {
81+
if err == mongo.ErrNoDocuments {
82+
return nil, repo.ErrResourceNotFound
83+
}
84+
return nil, err
85+
}
86+
87+
return prj, nil
7888
}
7989

8090
func (r *Project) FindByIDs(ctx context.Context, ids id.ProjectIDList) ([]*project.Project, error) {
@@ -479,7 +489,7 @@ func (r *Project) FindActiveById(ctx context.Context, id id.ProjectID) (*project
479489
prj, err := r.findOne(ctx, bson.M{
480490
"id": id.String(),
481491
"deleted": false,
482-
}, true)
492+
}, false)
483493

484494
if err != nil {
485495
if err == mongo.ErrNoDocuments {
@@ -495,7 +505,7 @@ func (r *Project) FindActiveByAlias(ctx context.Context, alias string) (*project
495505
prj, err := r.findOne(ctx, bson.M{
496506
"alias": alias,
497507
"deleted": false,
498-
}, true)
508+
}, false)
499509

500510
if err != nil {
501511
if err == mongo.ErrNoDocuments {
@@ -508,9 +518,10 @@ func (r *Project) FindActiveByAlias(ctx context.Context, alias string) (*project
508518
}
509519

510520
func (r *Project) FindByProjectAlias(ctx context.Context, alias string) (*project.Project, error) {
521+
511522
prj, err := r.findOne(ctx, bson.M{
512523
"projectalias": alias,
513-
}, true)
524+
}, false)
514525

515526
if err != nil {
516527
if err == mongo.ErrNoDocuments {

0 commit comments

Comments
 (0)