فهرست منبع

修改登录新增登录模式
修改了必须使用复杂密码

Administrator 2 سال پیش
والد
کامیت
7c5a91c2b6

+ 5 - 0
boman-auth/src/main/java/com/boman/auth/controller/TokenController.java

@@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
+import static com.boman.common.core.utils.SecurityUtils.checkStrongPwd;
+
 
 /**
  * token 控制
@@ -52,6 +54,9 @@ public class TokenController {
             }
             openId = (String) jsonObject.get("openId");
         }
+        if ("1".equals(checkStrongPwd(form.getPassword()))) {
+            return R.fail("密码必须包含数字、大小写字母、特殊符号且大于8位");
+        }
         // 用户登录
         LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
         // 如果是微信登录并且获取到的用户的unionId不为空

+ 29 - 8
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysUserController.java

@@ -15,14 +15,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import com.boman.domain.constant.UserConstants;
 import com.boman.domain.dto.R;
@@ -276,6 +269,34 @@ public class SysUserController extends BaseController {
         return toAjax(userService.resetPwd(user));
     }
 
+    @PutMapping("/resetPwdLogin")
+    public AjaxResult resetPwdLogin(@RequestParam("userName") String userName,@RequestParam("oldPassword") String oldPassword,@RequestParam("newPassword") String newPassword) {
+        //userService.checkUserAllowed(user);
+        if ("admin".equals(userName)){
+            return AjaxResult.error("不允许操作超级管理员");
+        }
+        SysUser user = userService.selectUserByUserName(userName);
+        if (user == null){
+            return AjaxResult.error("当前用户不存在");
+        }
+        String password = user.getPassword();
+        if (!SecurityUtils.matchesPassword(oldPassword, password))
+        {
+            return AjaxResult.error("修改密码失败,旧密码错误");
+        }
+        if (SecurityUtils.matchesPassword(newPassword, password))
+        {
+            return AjaxResult.error("新密码不能与旧密码相同");
+        }
+
+        if ("1".equals(checkStrongPwd(newPassword))) {
+            return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
+        }
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+        user.setUpdateBy(userName);
+        return toAjax(userService.resetPwdLogin(user));
+    }
+
     /**
      * 状态修改
      */

+ 1 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysUserMapper.java

@@ -52,6 +52,7 @@ public interface SysUserMapper
      * @return 结果
      */
     public int updateUser(SysUser user);
+    public int updateUserByUserName(SysUser user);
 
     /**
      * 修改用户头像

+ 7 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysUserService.java

@@ -132,6 +132,13 @@ public interface ISysUserService
      * @return 结果
      */
     public int resetPwd(SysUser user);
+    /**
+     * 登录页重置用户密码
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    public int resetPwdLogin(SysUser user);
 
     /**
      * 重置用户密码

+ 11 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysUserServiceImpl.java

@@ -297,6 +297,17 @@ public class SysUserServiceImpl implements ISysUserService
         return userMapper.updateUser(user);
     }
 
+    /**
+     * 登录页重置用户密码
+     * @param user 用户信息
+     * @return
+     */
+    @Override
+    public int resetPwdLogin(SysUser user) {
+        return userMapper.updateUserByUserName(user);
+
+    }
+
     /**
      * 重置用户密码
      * 

+ 9 - 1
boman-modules/boman-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -161,7 +161,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		</set>
  		where id = #{id}
 	</update>
-	
+	<update id="updateUserByUserName" parameterType="com.boman.domain.SysUser">
+		update sys_user
+		<set>
+			<if test="password != null and password != ''">password = #{password},</if>
+			update_time = sysdate()
+		</set>
+		where user_name = #{userName}
+	</update>
+
 	<update id="updateUserStatus" parameterType="com.boman.domain.SysUser">
  		update sys_user set status = #{status} where id = #{id}
 	</update>