1414@ RestController
1515@ RequestMapping ("${api.path}/auth" )
1616@ RequiredArgsConstructor
17- @ Tag (name = "Аутентификация " , description = "Для аутентификации, регистрации, обновлении и запроса токенов и отправки запросов кода на почту." )
17+ @ Tag (name = "Authentication " , description = "Для аутентификации, регистрации, обновлении и запроса токенов и отправки запросов кода на почту." )
1818public class AuthController {
1919
2020 private final AuthService authService ;
@@ -25,9 +25,8 @@ public class AuthController {
2525 summary = "Запросить код по почте" ,
2626 description = "Запрос на получение кода авторизации по почте"
2727 )
28- public ResponseEntity <JwtResponse > login (@ RequestBody CodeRequest codeRequest ) {
29- verificationCodeService .generateAndSendCode (codeRequest .getEmail ());
30- return ResponseEntity .ok ().build ();
28+ public ResponseEntity <CodeResponse > requestCode (@ RequestBody CodeRequest codeRequest ) {
29+ return ResponseEntity .ok (verificationCodeService .generateAndSendCode (codeRequest .getEmail ()));
3130 }
3231
3332 @ Operation (
@@ -68,6 +67,32 @@ public ResponseEntity<JwtResponse> login(@RequestBody JwtRequest authRequest/*,
6867 .body (tokens );
6968 }
7069
70+ @ Operation (
71+ summary = "Запрос на регистрацию" ,
72+ description = "Получает email и код с почты, а также имя и фамилию пользователя. Возвращает JWT токены"
73+ )
74+ @ PostMapping ("/register" )
75+ public ResponseEntity <JwtResponse > register (@ RequestBody RegisterRequest registerRequest /*,
76+ HttpServletResponse response*/ ) throws AuthException {
77+ JwtResponse tokens = authService .register (registerRequest );
78+
79+ return ResponseEntity .ok ()
80+ .body (tokens );
81+ }
82+
83+ @ Operation (
84+ summary = "Проверка валидности введенного кода пользователем" ,
85+ description = "Проверяет правильность введенного кода, отправленного на почту. Использовать в случае, если пользователь новый."
86+ )
87+ @ PostMapping ("/validate-code" )
88+ public ResponseEntity <Void > checkCode (@ RequestBody JwtRequest authRequest /*,
89+ HttpServletResponse response*/ ) throws AuthException {
90+ authService .validateCode (authRequest );
91+ return ResponseEntity .ok ().build ();
92+ }
93+
94+
95+
7196 @ Operation (
7297 summary = "Запрос на обновление AccessToken'а" ,
7398 description = "Получает RefreshToken, возвращает новый AccessToken"
0 commit comments