Skip to content

Commit

Permalink
fix(server): check app auth by createdBy (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatal committed Aug 11, 2023
1 parent 57800c4 commit e2be923
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions server/src/application/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,15 @@ export class ApplicationService {
.collection<Application>('Application')
.aggregate()
.match({
phase: { $ne: ApplicationPhase.Deleted },
appid: { $in: doc.map((v) => v.appid) },
$and: [
{
$or: [
{ appid: { $in: doc.map((v) => v.appid) } },
{ createdBy: userid },
],
},
{ phase: { $ne: ApplicationPhase.Deleted } },
],
})
.lookup({
from: 'ApplicationBundle',
Expand Down
2 changes: 1 addition & 1 deletion server/src/authentication/application.auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ApplicationAuthGuard implements CanActivate {
}

const ok = await this.checkGroupAuth(appid, user, context)
if (!ok) {
if (!ok && !app.createdBy.equals(user._id)) {
return false
}

Expand Down

0 comments on commit e2be923

Please sign in to comment.