Facebook
From Morose Gibbon, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 109
  1.     @RequestMapping(value = "login-success", method = RequestMethod.GET)
  2.     public void createAuthenticationToken(HttpServletRequest request, HttpServletResponse response, @CookieValue(HttpCookieUtils.TOKEN) String temporaryToken) throws IOException {
  3.         HttpCookieUtils.deleteCookiesFromResponse(request, response, Set.of(HttpCookieUtils.TOKEN));
  4.         String username = jwtParser.getUsernameFromToken(temporaryToken);
  5.         UserDetails userDetails = userDetailsService.loadUserByUsername(username);
  6.  
  7.         if (jwtParser.validateToken(temporaryToken, userDetails, JwtToken.TEMPORARY_TOKEN)) {
  8.             String accessToken = jwtParser.generateToken(userDetails, JwtToken.ACCESS_TOKEN);
  9.             String refreshToken = jwtParser.generateToken(userDetails, JwtToken.REFRESH_TOKEN);
  10.  
  11.  
  12.             response.sendRedirect("http://localhost:4201/login_process/" + accessToken);
  13.         }
  14.     }