mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 08:13:49 +10:00
- upgrade react-resizable-panels to latest version
- update translations - remove cypress - add await to all return blocks
This commit is contained in:
@ -152,8 +152,6 @@ export class AuthService {
|
||||
const text = `Please click on the link below to reset your password:\n\n${url}`;
|
||||
|
||||
await this.mailService.sendEmail({ to: email, subject, text });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
async updatePassword(email: string, password: string) {
|
||||
@ -188,8 +186,6 @@ export class AuthService {
|
||||
const text = `Please verify your email address by clicking on the link below:\n\n${url}`;
|
||||
|
||||
await this.mailService.sendEmail({ to: email, subject, text });
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException(error);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export class LocalStrategy extends PassportStrategy(Strategy, "local") {
|
||||
|
||||
async validate(identifier: string, password: string) {
|
||||
try {
|
||||
return this.authService.authenticate({ identifier, password });
|
||||
return await this.authService.authenticate({ identifier, password });
|
||||
} catch (error) {
|
||||
throw new BadRequestException(ErrorMessage.InvalidCredentials);
|
||||
}
|
||||
|
||||
@ -32,9 +32,9 @@ export class PrinterService {
|
||||
this.browserURL = `${chromeUrl}?token=${chromeToken}`;
|
||||
}
|
||||
|
||||
private getBrowser() {
|
||||
private async getBrowser() {
|
||||
try {
|
||||
return connect({ browserWSEndpoint: this.browserURL });
|
||||
return await connect({ browserWSEndpoint: this.browserURL });
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException(ErrorMessage.InvalidBrowserConnection, error.message);
|
||||
}
|
||||
|
||||
@ -47,9 +47,9 @@ export class ResumeController {
|
||||
|
||||
@Post()
|
||||
@UseGuards(TwoFactorGuard)
|
||||
create(@User() user: UserEntity, @Body() createResumeDto: CreateResumeDto) {
|
||||
async create(@User() user: UserEntity, @Body() createResumeDto: CreateResumeDto) {
|
||||
try {
|
||||
return this.resumeService.create(user.id, createResumeDto);
|
||||
return await this.resumeService.create(user.id, createResumeDto);
|
||||
} catch (error) {
|
||||
if (error instanceof PrismaClientKnownRequestError && error.code === "P2002") {
|
||||
throw new BadRequestException(ErrorMessage.ResumeSlugAlreadyExists);
|
||||
@ -61,9 +61,9 @@ export class ResumeController {
|
||||
|
||||
@Post("import")
|
||||
@UseGuards(TwoFactorGuard)
|
||||
import(@User() user: UserEntity, @Body() importResumeDto: ImportResumeDto) {
|
||||
async import(@User() user: UserEntity, @Body() importResumeDto: ImportResumeDto) {
|
||||
try {
|
||||
return this.resumeService.import(user.id, importResumeDto);
|
||||
return await this.resumeService.import(user.id, importResumeDto);
|
||||
} catch (error) {
|
||||
if (error instanceof PrismaClientKnownRequestError && error.code === "P2002") {
|
||||
throw new BadRequestException(ErrorMessage.ResumeSlugAlreadyExists);
|
||||
|
||||
@ -136,7 +136,7 @@ export class StorageService implements OnModuleInit {
|
||||
const path = `${userId}/${type}/${filename}.${extension}`;
|
||||
|
||||
try {
|
||||
return Promise.all([
|
||||
return await Promise.all([
|
||||
this.redis.del(`user:${userId}:storage:${type}:${filename}`),
|
||||
this.client.removeObject(this.bucketName, path),
|
||||
]);
|
||||
@ -157,7 +157,7 @@ export class StorageService implements OnModuleInit {
|
||||
}
|
||||
|
||||
try {
|
||||
return this.client.removeObjects(this.bucketName, objectsList);
|
||||
return await this.client.removeObjects(this.bucketName, objectsList);
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException(
|
||||
`There was an error while deleting the folder at the specified path: ${this.bucketName}/${prefix}.`,
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
import { Body, Controller, Delete, Get, Patch, Res, UseGuards } from "@nestjs/common";
|
||||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Patch,
|
||||
Res,
|
||||
UseGuards,
|
||||
} from "@nestjs/common";
|
||||
import { ApiTags } from "@nestjs/swagger";
|
||||
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
|
||||
import { UpdateUserDto, UserDto } from "@reactive-resume/dto";
|
||||
import { ErrorMessage } from "@reactive-resume/utils";
|
||||
import type { Response } from "express";
|
||||
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
@ -25,24 +37,32 @@ export class UserController {
|
||||
@Patch("me")
|
||||
@UseGuards(TwoFactorGuard)
|
||||
async update(@User("email") email: string, @Body() updateUserDto: UpdateUserDto) {
|
||||
// If user is updating their email, send a verification email
|
||||
if (updateUserDto.email && updateUserDto.email !== email) {
|
||||
await this.userService.updateByEmail(email, {
|
||||
emailVerified: false,
|
||||
email: updateUserDto.email,
|
||||
try {
|
||||
// If user is updating their email, send a verification email
|
||||
if (updateUserDto.email && updateUserDto.email !== email) {
|
||||
await this.userService.updateByEmail(email, {
|
||||
emailVerified: false,
|
||||
email: updateUserDto.email,
|
||||
});
|
||||
|
||||
await this.authService.sendVerificationEmail(updateUserDto.email);
|
||||
|
||||
email = updateUserDto.email;
|
||||
}
|
||||
|
||||
return await this.userService.updateByEmail(email, {
|
||||
name: updateUserDto.name,
|
||||
picture: updateUserDto.picture,
|
||||
username: updateUserDto.username,
|
||||
locale: updateUserDto.locale,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof PrismaClientKnownRequestError && error.code === "P2002") {
|
||||
throw new BadRequestException(ErrorMessage.UserAlreadyExists);
|
||||
}
|
||||
|
||||
await this.authService.sendVerificationEmail(updateUserDto.email);
|
||||
|
||||
email = updateUserDto.email;
|
||||
throw new InternalServerErrorException(error);
|
||||
}
|
||||
|
||||
return this.userService.updateByEmail(email, {
|
||||
name: updateUserDto.name,
|
||||
picture: updateUserDto.picture,
|
||||
username: updateUserDto.username,
|
||||
locale: updateUserDto.locale,
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("me")
|
||||
|
||||
@ -45,7 +45,7 @@ export class UserService {
|
||||
|
||||
// Otherwise, find the user by username
|
||||
// If the user doesn't exist, throw an error
|
||||
return this.prisma.user.findUniqueOrThrow({
|
||||
return await this.prisma.user.findUniqueOrThrow({
|
||||
where: { username: identifier },
|
||||
include: { secrets: true },
|
||||
});
|
||||
@ -59,11 +59,11 @@ export class UserService {
|
||||
}
|
||||
|
||||
async create(data: Prisma.UserCreateInput) {
|
||||
return this.prisma.user.create({ data, include: { secrets: true } });
|
||||
return await this.prisma.user.create({ data, include: { secrets: true } });
|
||||
}
|
||||
|
||||
async updateByEmail(email: string, data: Prisma.UserUpdateArgs["data"]) {
|
||||
return this.prisma.user.update({ where: { email }, data });
|
||||
return await this.prisma.user.update({ where: { email }, data });
|
||||
}
|
||||
|
||||
async updateByResetToken(resetToken: string, data: Prisma.SecretsUpdateArgs["data"]) {
|
||||
@ -73,6 +73,6 @@ export class UserService {
|
||||
async deleteOneById(id: string) {
|
||||
await Promise.all([this.redis.del(`user:${id}:*`), this.storageService.deleteFolder(id)]);
|
||||
|
||||
return this.prisma.user.delete({ where: { id } });
|
||||
return await this.prisma.user.delete({ where: { id } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user