提交代码

dev_xds
姜玉琦 2024-04-22 22:10:38 +08:00
parent 5561d11cb3
commit 64a606452e
2 changed files with 13 additions and 6 deletions

View File

@ -5,6 +5,8 @@ import javax.annotation.Resource;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
@ -41,6 +43,8 @@ import com.ruoyi.system.service.ISysUserService;
@Component
public class SysLoginService
{
private static final Logger log = LoggerFactory.getLogger(SysLoginService.class);
@Autowired
private TokenService tokenService;
@ -167,13 +171,15 @@ public class SysLoginService
//进入这里先把用户的密码修改,登录成功后在修改回去
SysUser sysUser = sysUserMapper.selectUserByUserName(username);
String userAuth = sysUser.getPassword();
String password = Convert.toStr(System.currentTimeMillis());
sysUser.setPassword(SecurityUtils.encryptPassword(password));
sysUserMapper.updateUser(sysUser);
// 用户验证
Authentication authentication = null;
try
{
String password = Convert.toStr(System.currentTimeMillis());
sysUser.setPassword(SecurityUtils.encryptPassword(password));
sysUserMapper.updateUser(sysUser);
log.info("【password】...密文==>{}",sysUser.getPassword());
log.info("【"+username+"】...临时登录密码是==>{},旧密码是==>{}",password,userAuth);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
@ -194,9 +200,10 @@ public class SysLoginService
}
finally
{
AuthenticationContextHolder.clearContext();
sysUser.setPassword(userAuth);
sysUserMapper.updateUser(sysUser);
log.info("【"+username+"】...密码已更新==>{}",userAuth);
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();

View File

@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test='nowRole == "5" or nowRole == "6" or nowRole == "7"'>
and sp.id in (select spui.projectId from sur_project_unit_info spui where spui.unitId = #{nowDept} and spui.job_type='24' and spui.del_flag=0 )
</if>
<if test='nowRole == "15" or nowRole == "16" or nowRole == "17"'> and fl.approve_status in ('10','20','21','30','31','100') and sp.id in (select spui.project_id from sur_project_userinfo spui where spui.dept_id = #{nowDept} and spui.user_id=#{nowUser} and spui.job_type='24' and spui.is_del=0)</if>
<if test='nowRole == "15" or nowRole == "16" or nowRole == "17"'> and fl.approve_status in ('10','20','21','30','31','100') and sp.id in (select spui.project_id from sur_project_userinfo spui where spui.dept_id = #{nowDept} and spui.user_id=(select su.user_id from sys_user su where su.user_name=#{nowUser}) and spui.job_type='24' and spui.is_del=0)</if>
<if test='activeName == "jxz"'>
<if test='nowRole == "4"'> and fl.approve_status in ('20','31')</if>
<!--监理单位/总包公司/分包单位查询当前关联数据-->
@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test='nowRole == "4"'> and fl.approve_status in ('20','21','31','30','100') and sp.deptId = #{nowDept}</if>
<!--监理单位/总包公司/分包单位查询当前关联数据-->
<if test='nowRole == "5" or nowRole == "6" or nowRole == "7"'> and fl.approve_status in ('10','20','21','30','31','100') and sp.id in (select spui.projectId from sur_project_unit_info spui where spui.unitId = #{nowDept} and spui.job_type='24' and spui.del_flag=0 )</if>
<if test='nowRole == "15" or nowRole == "16" or nowRole == "17"'> and fl.approve_status in ('10','20','21','30','31','100') and sp.id in (select spui.project_id from sur_project_userinfo spui where spui.dept_id = #{nowDept} and spui.user_id=#{nowUser} and spui.job_type='24' and spui.is_del=0)</if>
<if test='nowRole == "15" or nowRole == "16" or nowRole == "17"'> and fl.approve_status in ('10','20','21','30','31','100') and sp.id in (select spui.project_id from sur_project_userinfo spui where spui.dept_id = #{nowDept} and spui.user_id=(select su.user_id from sys_user su where su.user_name=#{nowUser}) and spui.job_type='24' and spui.is_del=0)</if>
</where>
group by fl.approve_status
</select>