| | |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletContext; |
| | |
| | | return new Response().set(0,false,"新密码修改失败"); |
| | | } |
| | | } |
| | | //密码失效修改密码 |
| | | public Response updatePasswordByValidity(String uname, String oldPwd, String newPwd){ |
| | | //验证旧密码是否正确 |
| | | QueryWrapper<UserInf> queryWrapper = Wrappers.query(); |
| | | queryWrapper.select("uid","upassword").eq("uName",uname).last(" limit 1"); |
| | | UserInf user=userMapper.selectOne(queryWrapper); |
| | | String passwordDB =user.getUpassword(); |
| | | if(!RSAUtil.decrypt(passwordDB,RSAUtil.getPrivateKey()).equals(oldPwd)){ |
| | | return new Response().set(1,false,"旧密码输入错误"); |
| | | } |
| | | if(!ActionUtil.filterPwd(newPwd)){ |
| | | return new Response().set(0,false,"新密码验证不通过(最少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符)"); |
| | | } |
| | | String[] dataArr = RSAUtil.decryptFrontP(newPwd, RSAUtil.fontSeparator); |
| | | newPwd = dataArr[0]; |
| | | String passwordMD5 = dataArr[1]; |
| | | if(!ActionUtil.EncryptionMD5(newPwd).equals(passwordMD5)){ |
| | | throw new InvalidParameterException("参数校验失败"); |
| | | } |
| | | String pwd = RSAUtil.encrypt(newPwd,RSAUtil.getPublicKey()); |
| | | user.setUpassword(pwd); |
| | | user.setUSnId(pwd); |
| | | user.setPasswordUpdateTime(new Date()); |
| | | if (userMapper.updateById(user)>0){ |
| | | return new Response().set(1,true,"新密码修改成功"); |
| | | }else { |
| | | return new Response().set(0,false,"新密码修改失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | public Response updatePassword2(UserInf userInf, String passwordOld, String passwordNew) { |