Add refresh token generation

This commit is contained in:
Dmitrii Cravcenco
2023-10-12 12:52:39 +03:00
parent b1b13dc736
commit f8ec901fa8
7 changed files with 79 additions and 24 deletions

View File

@@ -1,19 +1,17 @@
package com.faf223.expensetrackerfaf.controller.auth;
import com.faf223.expensetrackerfaf.service.AuthenticationService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("api/v1/auth")
@RequiredArgsConstructor
public class AuthenticationController {
private final AuthenticationService service;
public AuthenticationController(AuthenticationService service) {
this.service = service;
}
@PostMapping("/register")
public ResponseEntity<AuthenticationResponse> register(@RequestBody RegisterRequest request) {
return ResponseEntity.ok(service.register(request));
@@ -24,8 +22,8 @@ public class AuthenticationController {
return ResponseEntity.ok(service.authenticate(request));
}
@PostMapping("/refresh")
public ResponseEntity<AuthenticationResponse> refreshAccessToken(@RequestBody TokenRefreshRequest refreshRequest) {
return ResponseEntity.ok(service.refreshAccessToken(refreshRequest));
@PostMapping("/refreshtoken")
public ResponseEntity<AuthenticationResponse> refreshAccessToken(@RequestBody TokenRefreshRequest request) {
return ResponseEntity.ok(service.refreshAccessToken(request));
}
}