77.1. Add new user (#9 Section 11: User Resource)
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
package net.shyshkin.study.fullstack.supportportal.backend.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.constant.SecurityConstants;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.domain.HttpResponse;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.domain.User;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.UserDto;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.service.UserService;
|
||||
import net.shyshkin.study.fullstack.supportportal.backend.utility.JwtTokenProvider;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -15,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("user")
|
||||
@RequiredArgsConstructor
|
||||
@ -53,6 +55,12 @@ public class UserResource {
|
||||
.body(httpResponse);
|
||||
}
|
||||
|
||||
@PostMapping("add")
|
||||
public User addNewUser(UserDto userDto) {
|
||||
log.debug("User DTO: {}", userDto);
|
||||
return userService.addNewUser(userDto);
|
||||
}
|
||||
|
||||
private void authenticate(String username, String password) {
|
||||
Authentication auth = new UsernamePasswordAuthenticationToken(username, password);
|
||||
authenticationManager.authenticate(auth);
|
||||
|
||||
Reference in New Issue
Block a user