Framework/Spring Boot
개인정보 수정
잔망루피
2022. 2. 5. 22:09
@GetMapping("/user/form") // 개인정보 수정
public String updateForm(Model model){
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String id=authentication.getName(); // 로그인한 유저 id
model.addAttribute("user", userService.findByUsername(id).get());
return "/user/updateForm";
}
유저 아이디를 이용해서 객체를 찾아 model에 담았다.
<a role="button" class="btn btn-link my-2 mr-2 my-sm-0" th:href="@{/user/form}" sec:authorize="isAuthenticated()" style="color : #FFFFFF">개인정보수정</a>
개인정보수정 버튼은 사용자가 로그인했을 때 보인다.
참고 👇
[SpringSecurity] Authentication(인증) 관련 클래스와 처리
Spring Security에 대해 큰 흐름은 알지만, 처음부터 적용하는게 아니면 어떤 권한을 주고 권한 체크하는 로직만 추가하거나 수정하며 생각없이 쓰게 되는데, 어떤 흐름으로 되는지 전보다 좀 더 살
flyburi.com
https://okky.kr/article/418782
OKKY | 스프링 시큐리티 회원정보 수정 페이지의 현재 유저 정보를 호출하는 방법
안녕하세요. 독학으로 스프링 시큐리티를 사용하다가 막혀서 질문 드립니다. 현재 기본적인 기능(로그인/회원가입 등)은 작성이 된 상태입니다. 여기에서 개인정보 수정( 회원정보 라고 하겠습
okky.kr
반응형