@RequestMapping(value = "nickname", method = RequestMethod.PUT) ResponseEntity<UserDto> updateNickname( @AuthenticationPrincipal BeadsanUserDetails userDetail, @Validated @RequestBody UserDto userDto, HttpServletRequest request, HttpServletResponse response) { if (!userDetail.getUserInfo().getMailAddress().equals(userDto.getMailAddress())) { UserDto errorUserDto = new UserDto(); errorUserDto.setMessage("ログイン時と異なるメールアドレスです"); return new ResponseEntity<>(null, null, HttpStatus.NOT_ACCEPTABLE); } UserDto outDto = userService.updateNickname(userDto); return new ResponseEntity<>(outDto, null, HttpStatus.OK); }
@RequestMapping(value = "auth", method = RequestMethod.GET) ResponseEntity<PageDto> isAuth(@AuthenticationPrincipal BeadsanUserDetails userDetail) { PageDto pageDto = new PageDto(); if (userDetail != null) { UserInfo userInfo = userDetail.getUserInfo(); HeaderDto headerDto = mapper.map(userInfo, HeaderDto.class); headerDto.setAuth(true); LoginDto loginDto = mapper.map(userInfo, LoginDto.class); pageDto.setHeaderDto(headerDto); pageDto.setLoginDto(loginDto); return new ResponseEntity<>(pageDto, null, HttpStatus.OK); } else { HeaderDto headerDto = new HeaderDto(); headerDto.setAuth(false); pageDto.setHeaderDto(headerDto); return new ResponseEntity<>(pageDto, null, HttpStatus.UNAUTHORIZED); } }