Skip to content

Commit 7398df1

Browse files
committed
implement userLoginResponseDto
1 parent 0534029 commit 7398df1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/users/users.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CreateUserDto } from './dto/create-user.dto';
44
import { UsersService } from './users.service';
55
import { UserDto } from './dto/user.dto';
66
import { ApiUseTags, ApiOkResponse } from '@nestjs/swagger';
7+
import { UserLoginResponseDto } from './dto/user-login-response.dto';
78

89
@Controller('users')
910
@ApiUseTags('users')
@@ -20,7 +21,7 @@ export class UsersController {
2021
@HttpCode(200)
2122
async login(
2223
@Body() userLoginRequestDto: UserLoginRequestDto,
23-
): Promise<string> {
24+
): Promise<UserLoginResponseDto> {
2425
return this.usersService.login(userLoginRequestDto);
2526
}
2627

src/users/users.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { UserDto } from './dto/user.dto';
55
import { UserLoginRequestDto } from './dto/user-login-request.dto';
66
import { CreateUserDto } from './dto/create-user.dto';
77
import { AuthService } from './../shared/auth/auth.service';
8+
import { UserLoginResponseDto } from './dto/user-login-response.dto';
89

910
@Injectable()
1011
export class UsersService {
@@ -53,7 +54,9 @@ export class UsersService {
5354
}
5455
}
5556

56-
async login(userLoginRequestDto: UserLoginRequestDto): Promise<string> {
57+
async login(
58+
userLoginRequestDto: UserLoginRequestDto,
59+
): Promise<UserLoginResponseDto> {
5760
const email = userLoginRequestDto.email;
5861
const password = userLoginRequestDto.password;
5962

@@ -73,6 +76,7 @@ export class UsersService {
7376
);
7477
}
7578

76-
return await this.authService.signToken(user);
79+
const token = await this.authService.signToken(user);
80+
return new UserLoginResponseDto(user, token);
7781
}
7882
}

0 commit comments

Comments
 (0)