| | |
| | | AuthenticationContextHolder.setContext(authenticationToken); |
| | | // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername |
| | | authentication = authenticationManager.authenticate(authenticationToken); |
| | | |
| | | // 获取用户ID |
| | | LoginUser loginUser = (LoginUser) userDetailsService.loadUserByUsername(username); |
| | | Long userId = loginUser.getUser().getUserId(); |
| | | // 登录成功逻辑 |
| | | if (authentication.isAuthenticated()) { |
| | | // 检查是否已登录 |
| | | successHandler.onAuthenticationSuccess(userId); |
| | | successHandler.onAuthenticationSuccess(authentication); |
| | | } |
| | | } |
| | | catch (Exception e) |