Add JWT authorization

This commit is contained in:
DmitriiCravcenco
2023-10-02 08:18:57 +03:00
parent 4775911e50
commit 35fb05ac01
13 changed files with 423 additions and 70 deletions

View File

@@ -0,0 +1,26 @@
package com.faf223.expensetrackerfaf.controller.auth;
import com.faf223.expensetrackerfaf.service.AuthenticationService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("api/v1/auth")
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));
}
@PostMapping("/authenticate")
public ResponseEntity<AuthenticationResponse> register(@RequestBody AuthenticationRequest request) {
return ResponseEntity.ok(service.authenticate(request));
}
}