Merge pull request #246 from SyncrowIOT/fix-null-user-issue

Add optional chaining to user and invitedUser checks
This commit is contained in:
faris Aljohari
2025-02-04 07:25:15 -06:00
committed by GitHub

View File

@ -181,7 +181,7 @@ export class InviteUserService {
where: { email }, where: { email },
relations: ['project'], relations: ['project'],
}); });
if (!user.isActive) { if (!user?.isActive) {
throw new HttpException('This user is deleted', HttpStatus.BAD_REQUEST); throw new HttpException('This user is deleted', HttpStatus.BAD_REQUEST);
} }
if (user?.project) { if (user?.project) {
@ -195,7 +195,7 @@ export class InviteUserService {
where: { email }, where: { email },
relations: ['project'], relations: ['project'],
}); });
if (!invitedUser.isActive) { if (!invitedUser?.isActive) {
throw new HttpException('This user is deleted', HttpStatus.BAD_REQUEST); throw new HttpException('This user is deleted', HttpStatus.BAD_REQUEST);
} }
if (invitedUser?.project) { if (invitedUser?.project) {