| | |
| | | // 登录前置校验 |
| | | loginPreCheck(username, password); |
| | | // 用户验证 |
| | | Authentication authentication = null; |
| | | // Authentication authentication = null; |
| | | // 用户验证 |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | if (StringUtils.isNull(user)){ |
| | |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username+"_", password); |
| | | AuthenticationContextHolder.setContext(authenticationToken); |
| | | // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername |
| | | authentication = authenticationManager.authenticate(authenticationToken); |
| | | // authentication = authenticationManager.authenticate(authenticationToken); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | AuthenticationContextHolder.clearContext(); |
| | | } |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal(); |
| | | LoginUser loginUser = new LoginUser(); |
| | | loginUser.setUser(user); |
| | | loginUser.setUserId(user.getUserId()); |
| | | loginUser.setNickName(user.getNickName()); |
| | | loginUser.setRoleType(user.getRoleType()); |
| | | loginUser.setObjectId(user.getObjectId()); |