150. Test login - Part 3 - CORS enabled (#18)
This commit is contained in:
@ -2,6 +2,7 @@ package net.shyshkin.study.fullstack.supportportal.backend.controller;
|
|||||||
|
|
||||||
import net.shyshkin.study.fullstack.supportportal.backend.domain.HttpResponse;
|
import net.shyshkin.study.fullstack.supportportal.backend.domain.HttpResponse;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ import static net.shyshkin.study.fullstack.supportportal.backend.utility.HttpRes
|
|||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@CrossOrigin("http://localhost:4200")
|
||||||
public class ErrorController {
|
public class ErrorController {
|
||||||
|
|
||||||
@GetMapping("/error")
|
@GetMapping("/error")
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import static org.springframework.http.HttpStatus.OK;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("user")
|
@RequestMapping("user")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@CrossOrigin("http://localhost:4200")
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
@ -47,6 +48,7 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
|
@CrossOrigin(value = "http://localhost:4200", exposedHeaders = {SecurityConstants.JWT_TOKEN_HEADER})
|
||||||
public ResponseEntity<User> login(@RequestBody User user) {
|
public ResponseEntity<User> login(@RequestBody User user) {
|
||||||
|
|
||||||
authenticate(user.getUsername(), user.getPassword());
|
authenticate(user.getUsername(), user.getPassword());
|
||||||
|
|||||||
Reference in New Issue
Block a user