Sửa đổi dữ liệu của hệ thống theo ARCHITECTURE.md

This commit is contained in:
2026-06-13 19:52:08 +07:00
parent 7fc80a49d0
commit b54707823c
33 changed files with 655 additions and 275 deletions
+7 -7
View File
@@ -16,12 +16,12 @@ let TourRoleGuard = class TourRoleGuard {
async canActivate(context) {
const request = context.switchToHttp().getRequest();
const user = request.user;
const tourId = parseInt(request.params.id || request.params.tourId);
const tourId = request.params.id || request.params.tourId;
const path = request.url;
if (!user || isNaN(tourId)) {
if (!user || !tourId) {
throw new ForbiddenException("Thông tin xác thực hoặc mã Tour không hợp lệ.");
}
const membership = await this.prisma.tourMember.findUnique({
const participation = await this.prisma.tourParticipant.findUnique({
where: {
tourId_userId: {
tourId: tourId,
@@ -29,14 +29,14 @@ let TourRoleGuard = class TourRoleGuard {
},
},
});
if (!membership) {
if (!participation) {
throw new ForbiddenException("Bạn không phải là thành viên của tour này.");
}
request.tourMembership = membership;
const role = membership.role;
request.tourParticipation = participation;
const role = participation.role;
const isPlanPath = path.includes('/plans');
const isExpensePath = path.includes('/expenses');
if ((role === 'MEMBER_PHOTO_ONLY' || role === 'VIEWER_EXTERNAL') &&
if ((role === 'MEMBER_NO_FINANCE' || role === 'VIEWER_ONLY') &&
(isPlanPath || isExpensePath)) {
throw new ForbiddenException("Bạn không có quyền xem kế hoạch và chi phí của tour này.");
}