| | |
| | | import com.vci.starter.web.annotation.bus.VciLoginAfter; |
| | | import com.vci.starter.web.annotation.bus.VciLogoutBefore; |
| | | import com.vci.starter.web.annotation.bus.VciLogoutPlugin; |
| | | import com.vci.starter.web.constant.VConstant; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.interceptor.VciSessionForLoginI; |
| | | import com.vci.starter.web.pagemodel.RequestClientInfo; |
| | |
| | | import com.vci.constant.CacheNameConstant; |
| | | import com.vci.dto.LoginUserDTO; |
| | | import com.vci.web.properties.WebProperties; |
| | | import com.vci.web.redis.RedisService; |
| | | import com.vci.starter.web.redis.RedisService; |
| | | import com.vci.web.service.LoginServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * 当前登录的用户总数key |
| | | */ |
| | | private static final String CURRENT_LOGGED_USERS_KEY = "current_logged_users"; |
| | | |
| | | /** |
| | | * 执行登录 |
| | | * @param userDTO 登录信息 |
| | | * @param clientInfo 请求的客户端的信息 |
| | |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数错误,用户不能登录等会抛出异常 |
| | | */ |
| | | private LoginResultBO login(LoginUserDTO userDTO, RequestClientInfo clientInfo, boolean checkPassword/*单点登录不需要校验密码*/) throws VciBaseException, PLException { |
| | | private LoginResultBO login(LoginUserDTO userDTO, RequestClientInfo clientInfo, boolean checkPassword/*单点登录不需要校验密码*/) throws VciBaseException { |
| | | LoginResultBO loginResult = new LoginResultBO(); |
| | | loginResult.setSuccess(false); |
| | | |
| | |
| | | String tokenKey = redisService.getCacheObject(userIdTokenKey); |
| | | redisService.deleteObject(tokenKey); |
| | | redisService.deleteObject(userIdTokenKey); |
| | | redisService.userLogout(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId()); |
| | | redisService.decreOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); |
| | | } |
| | | |
| | | //3.获取用户的对象(对象中包含角色部门还有密码策略信息(当前用户没设置密码策略就是取的默认密码策略)) |
| | |
| | | //初始化平台的token |
| | | sessionForLogin.initInvocationInfo(sessionInfo); |
| | | //记录当前登录人数的总数 |
| | | redisService.userLogin(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId()); |
| | | redisService.increOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); |
| | | //拷贝用户到新的session会话中 |
| | | copyUser2SessionInfo(user, sessionInfo, userDTO.getLangCode()); |
| | | //拷贝请求信息到session会话中 |
| | |
| | | |
| | | //3、判断密码是否正确 |
| | | if (checkPassword) { |
| | | boolean passwordIsEqual = userQueryService.checkPasswordEqual(userDTO.getPassword(), user.getOid()); |
| | | boolean passwordIsEqual = userQueryService.checkPasswordEqual(userDTO.getPassword(), user.getName()); |
| | | if (!passwordIsEqual) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("{}密码不正确", user.getId()); |
| | |
| | | }); |
| | | } |
| | | //清除存当前登录的用户(总数-1) |
| | | redisService.userLogout(CURRENT_LOGGED_USERS_KEY,WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()); |
| | | redisService.decreOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); |
| | | sessionForLogin.logout(userToken); |
| | | if(!CollectionUtils.isEmpty(logoutpluginBeanMap)){ |
| | | logoutpluginBeanMap.forEach((k,v) -> { |