Sửa đổi dữ liệu của hệ thống theo ARCHITECTURE.md
This commit is contained in:
Vendored
+7
-7
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user