fix: cho phép người đã tải ảnh lên được quyền chỉnh sửa
This commit is contained in:
+3
-1
@@ -129,8 +129,9 @@ export class TourRoleGuard implements CanActivate {
|
||||
tourId = loc.leg.tourId;
|
||||
} else {
|
||||
// Thử xem resourceId có phải là photoId không
|
||||
const photo = await this.prisma.photo.findUnique({ where: { id: resourceId }, select: { tourId: true } });
|
||||
const photo = await this.prisma.photo.findUnique({ where: { id: resourceId }, select: { tourId: true, uploaderId: true } });
|
||||
if (photo) {
|
||||
if (user && photo.uploaderId === user.id) return true; // Cho phép chủ sở hữu ảnh đi qua
|
||||
if (!photo.tourId) return true; // Cho phép đi qua nếu ảnh không thuộc tour nào (ví dụ ảnh ẩn danh public)
|
||||
tourId = photo.tourId;
|
||||
}
|
||||
@@ -2311,6 +2312,7 @@ class PublicPhotoController {
|
||||
originalUrl: true,
|
||||
capturedAt: true,
|
||||
metadata: true,
|
||||
uploaderId: true,
|
||||
uploader: {
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
Reference in New Issue
Block a user