mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-17 04:33:15 +02:00
fix: dto returns
This commit is contained in:
@@ -6,10 +6,11 @@ import {
|
||||
Post,
|
||||
} from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
import { AuthService } from "./auth.service";
|
||||
import { AuthDTO } from "./dto/auth.dto";
|
||||
import { AuthRegisterDTO } from "./dto/authRegister.dto";
|
||||
import { AuthSignInDTO } from "./dto/authSignIn.dto";
|
||||
import { RefreshAccessTokenDTO } from "./dto/refreshAccessToken.dto";
|
||||
|
||||
@Controller("auth")
|
||||
@@ -27,7 +28,7 @@ export class AuthController {
|
||||
}
|
||||
|
||||
@Post("signIn")
|
||||
signIn(@Body() dto: AuthDTO) {
|
||||
signIn(@Body() dto: AuthSignInDTO) {
|
||||
return this.authService.signIn(dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import { User } from "@prisma/client";
|
||||
import { PrismaClientKnownRequestError } from "@prisma/client/runtime";
|
||||
import * as argon from "argon2";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { AuthDTO } from "./dto/auth.dto";
|
||||
import { AuthRegisterDTO } from "./dto/authRegister.dto";
|
||||
import { AuthSignInDTO } from "./dto/authSignIn.dto";
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -44,7 +44,7 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
async signIn(dto: AuthDTO) {
|
||||
async signIn(dto: AuthSignInDTO) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: {
|
||||
email: dto.email,
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Expose, plainToClass } from "class-transformer";
|
||||
import { IsEmail, IsNotEmpty, IsString } from "class-validator";
|
||||
|
||||
export class AuthDTO {
|
||||
@Expose()
|
||||
id: string;
|
||||
|
||||
@Expose()
|
||||
firstName: string;
|
||||
|
||||
@Expose()
|
||||
lastName: string;
|
||||
|
||||
@Expose()
|
||||
@IsNotEmpty()
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
password: string;
|
||||
|
||||
constructor(partial: Partial<AuthDTO>) {
|
||||
return plainToClass(AuthDTO, partial, { excludeExtraneousValues: true });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { AuthDTO } from "./auth.dto";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
export class AuthRegisterDTO extends AuthDTO {}
|
||||
export class AuthRegisterDTO extends UserDTO {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { AuthDTO } from "./auth.dto";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
export class AuthSignInDTO extends PickType(AuthDTO, [
|
||||
export class AuthSignInDTO extends PickType(UserDTO, [
|
||||
"email",
|
||||
"password",
|
||||
] as const) {}
|
||||
|
||||
Reference in New Issue
Block a user