-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature/billing-plan-pagination
- Loading branch information
Showing
29 changed files
with
3,648 additions
and
3,347 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { Job } from '../modules/jobs/entities/job.entity'; | ||
import { User } from '@modules/user/entities/user.entity'; | ||
|
||
@Injectable() | ||
export class JobAccessGuard implements CanActivate { | ||
constructor( | ||
@InjectRepository(Job) | ||
private readonly jobRepository: Repository<Job>, | ||
@InjectRepository(User) | ||
private readonly userRepository: Repository<User> | ||
) {} | ||
|
||
async canActivate(context: ExecutionContext): Promise<boolean> { | ||
const request = context.switchToHttp().getRequest(); | ||
const jobId = request.params.id; | ||
const userId = request.user.sub; | ||
|
||
const user = await this.userRepository.findOne({ | ||
where: { id: userId }, | ||
}); | ||
|
||
if (user?.is_superadmin) { | ||
return true; | ||
} | ||
|
||
const job = await this.jobRepository.findOne({ | ||
where: { id: jobId }, | ||
relations: ['user'], | ||
}); | ||
|
||
if (!job) return false; | ||
return job.user.id === userId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsUUID } from 'class-validator'; | ||
|
||
export class DislikeCommentDto { | ||
@ApiProperty({ description: 'Comment ID to dislike' }) | ||
@IsNotEmpty() | ||
@IsUUID() | ||
commentId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { IsEmail, IsNotEmpty, IsOptional, IsString, Matches } from 'class-validator'; | ||
|
||
export class CreateContactDto { | ||
@IsNotEmpty({ message: 'Name should not be empty' }) | ||
@IsString({ message: 'Name must be a string' }) | ||
name: string; | ||
@IsNotEmpty({ message: 'Name should not be empty' }) | ||
@IsString({ message: 'Name must be a string' }) | ||
name: string; | ||
|
||
@IsNotEmpty({ message: 'Email should not be empty' }) | ||
@IsEmail({}, { message: 'Email must be valid' }) | ||
email: string; | ||
@IsNotEmpty({ message: 'Email should not be empty' }) | ||
@IsEmail({}, { message: 'Email must be valid' }) | ||
email: string; | ||
|
||
@IsOptional() | ||
@IsString({ message: 'Phone must be a string' }) | ||
@Matches(/^\+?[0-9\-\s()]{8,20}$/, { | ||
message: 'Invalid phone number format' | ||
}) | ||
phone: string; | ||
@IsOptional() | ||
@IsString({ message: 'Phone must be a string' }) | ||
@Matches(/^\+?[0-9\-\s()]{8,20}$/, { | ||
message: 'Invalid phone number format', | ||
}) | ||
phone: string; | ||
|
||
@IsNotEmpty({ message: 'Message should not be empty' }) | ||
@IsString({ message: 'Message must be a string' }) | ||
message: string; | ||
} | ||
@IsNotEmpty({ message: 'Message should not be empty' }) | ||
@IsString({ message: 'Message must be a string' }) | ||
message: string; | ||
} |
Oops, something went wrong.