-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6.30. Добавит метод
login
в UserController
.
Добавим в контроллер `UserController` метод `login`. Он будет использоваться для авторизации пользователя в системе. Авторизацию мы реализуем позже, а пока опишем одну проверку (существует пользователь или нет) и вернём в качестве результата «Not implemented». При реализации нам потребуется DTO — `LoginUserDto`. Поэтому создадим новый класс для DTO по аналогии с ранее созданными. Для тестирования обработчика сразу добавим запрос в `user.http`.
- Loading branch information
1 parent
cc55800
commit 25a27d2
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class LoginUserDto { | ||
public email: string; | ||
public password: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Request } from 'express'; | ||
|
||
import { RequestBody, RequestParams } from '../../libs/rest/index.js'; | ||
import { LoginUserDto } from './dto/login-user.dto.js'; | ||
|
||
export type LoginUserRequest = Request<RequestParams, RequestBody, LoginUserDto>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,15 @@ Content-Type: application/json | |
} | ||
|
||
### | ||
|
||
## Авторизовать пользователя | ||
|
||
POST http://localhost:4000/users/login HTTP/1.1 | ||
Content-Type: application/json | ||
|
||
{ | ||
"email": "[email protected]", | ||
"password": "shining" | ||
} | ||
|
||
### |