Skip to content

Commit

Permalink
Merge pull request #21 from LocalMingle/dev
Browse files Browse the repository at this point in the history
[수정] createdto 수정
  • Loading branch information
HeeDragoN1123 authored Oct 17, 2023
2 parents f40f01e + 7e99d1c commit 4fe4518
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export class AuthController {
@Req() req: Request,
@Res({ passthrough: true }) res: Response // Response 객체 주입
): Promise<void> {
const { accessToken, refreshToken, user } = await this.authService.login({

const { accessToken, refreshToken, userId } = await this.authService.login({

email,
password,
res,
Expand All @@ -65,7 +67,9 @@ export class AuthController {
// 리프레시 토큰을 HTTP 응답 헤더에 추가
res.header('refreshToken', refreshToken);

res.status(200).json({ user }); // 클라이언트에게 JSON 응답을 보냄

res.status(200).json({ userId }); // 클라이언트에게 JSON 응답을 보냄


//res.cookie('refreshToken', refreshToken, { httpOnly: true, secure: false });

Expand Down
12 changes: 9 additions & 3 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export class AuthService {
// 리팩토링 시 res 빼도 작동하는지 테스트
accessToken: string;
refreshToken: string;
user: User; // User 정보를 반환하기 위한 타입

//user: User; // User 정보를 반환하기 위한 타입
userId: number; // userId만 반환

}> {
// 1. 이메일이 일치하는 유저를 DB에서 찾기
const user = await this.usersService.findByEmail({ email });
Expand Down Expand Up @@ -53,7 +56,10 @@ export class AuthService {
// res.header('Authorization', `Bearer ${accessToken}`);
// res.header('RefreshToken', refreshToken);

return { accessToken, refreshToken, user }; //리턴값

//TODO : user값 대신 userId값만 넘어가게 수정해야함 ()
return { accessToken, refreshToken, userId: user.userId }; //리턴값

}

getAccessToken({ user, res }): string {
Expand Down Expand Up @@ -135,6 +141,6 @@ export class AuthService {
// 리다이렉션
res.redirect('http://127.0.0.1:5500'); // 메인페이지 url 을 입력해야합니다.

return { accessToken, refreshToken };
return { accessToken, refreshToken, userId: user.userId };
}
}
2 changes: 2 additions & 0 deletions src/users/dto/create-user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ export class CreateUserDto {

/* @IsOptional() */
@IsString()
@IsOptional()
@ApiProperty({
description: 'profileImg',
example: '프로필이미지 url',
})
profileImg?: string;

@IsString()
@IsOptional()
@ApiProperty({
description: 'refreshToken',
example: 'refreshToken',
Expand Down

0 comments on commit 4fe4518

Please sign in to comment.