Sfoglia il codice sorgente

设置密码为强密码

18339543638 1 anno fa
parent
commit
6e5c314959

+ 2 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/UserInfoVO.java

@@ -34,4 +34,6 @@ public class UserInfoVO implements Serializable {
     private List<RoleInfoVO> roles;
 
     private Boolean isSys;
+
+    private Boolean pswNeedReset;
 }

+ 9 - 1
nb-service/app-assistant/src/main/java/com/nb/app/assistant/service/LocalAppIphoneService.java

@@ -1,12 +1,13 @@
 package com.nb.app.assistant.service;
 
 import com.nb.app.assistant.dto.IphoneDeviceDTO;
+import com.nb.app.assistant.utils.ApnsUtils;
 import lombok.AllArgsConstructor;
 import org.redisson.api.RSet;
 import org.redisson.api.RedissonClient;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.PostConstruct;
+import java.util.Set;
 
 /**
  * @ClassName : LocalAppIphoneService
@@ -19,6 +20,7 @@ import javax.annotation.PostConstruct;
 public class LocalAppIphoneService {
     private final RedissonClient redissonClient;
 
+
     public void addDeviceToken(IphoneDeviceDTO source){
         RSet<String> tenantSet = redissonClient.getSet(source.getTenantId());
         tenantSet.add(source.getDeviceToken());
@@ -28,4 +30,10 @@ public class LocalAppIphoneService {
         RSet<String> tenantSet = redissonClient.getSet(source.getTenantId());
         tenantSet.remove(source.getDeviceToken());
     }
+
+    public void sendMsg(String tenantId){
+        RSet<String> tenantSet = redissonClient.getSet(tenantId);
+        tenantSet.readAll();
+//        ApnsUtils.sendMsg();
+    }
 }

+ 1 - 6
nb-service/app-assistant/src/main/java/com/nb/app/assistant/utils/ApnsUtils.java

@@ -61,12 +61,11 @@ public class ApnsUtils {
         //开始推送
         PushNotificationFuture<SimpleApnsPushNotification, PushNotificationResponse<SimpleApnsPushNotification>> future = getAPNSConnect().sendNotification(msg);
         PushNotificationResponse<SimpleApnsPushNotification> response = future.get();
-        System.out.println(response.getRejectionReason());
         //如果返回的消息中success为true那么成功,否则失败!
         //如果失败不必惊慌,rejectionReason字段中会有失败的原因。对应官网找到原因即可
         //https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns?language=objc
 
-        System.out.println("------------->"+response);
+        log.info("------------->"+response);
 
 
     }
@@ -93,8 +92,4 @@ public class ApnsUtils {
         }
         return apnsClient;
     }
-
-    public static void main(String[] args) throws Exception {
-        sendMsg("ad8b799839398e10d78c55041dbbe6483563cf75428e2ebe21162a75f83598b2","");
-    }
 }

+ 10 - 1
nb-service/web-service/src/main/java/com/nb/web/service/system/auth/WebAuthGranter.java

@@ -2,6 +2,7 @@ package com.nb.web.service.system.auth;
 
 import cn.dev33.satoken.spring.SpringMVCUtil;
 import cn.dev33.satoken.stp.StpLogic;
+import cn.hutool.Hutool;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -23,6 +24,7 @@ import com.nb.web.service.system.service.ISysMenuService;
 import com.nb.web.service.system.service.ISysRoleService;
 import com.nb.web.service.system.service.ISysUserService;
 import com.nb.web.service.system.utils.CaptchaTool;
+import com.nb.web.service.system.utils.PswUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -94,12 +96,19 @@ public class WebAuthGranter implements IAuthGranter {
             log.info("登录用户:{}已被停用", source.getUsername());
             throw new CustomException("对不起,您的账号已被停用");
         }
+
         log.info("登录用户:{}", source.getUsername());
+        boolean validatePsw = PswUtils.validatePsw(source.getPassword());
+        if(validatePsw){
+            sysUser.setPswNeedReset(true);
+        }else {
+            sysUser.setPswNeedReset(false);
+        }
+        sysUserService.updateById(sysUser);
         // 查询角色列表
         List<SysRole> sysRoleList = sysRoleService.listSysRoleByUserId(sysUser.getId(),String.valueOf(sysUser.getTenantId()));
         // 查询权限标识
         Set<String> permissions  = sysMenuService.getPermissionsByUserId(sysUser.getId());
-
         // 登录
         StpLogic stpLogic = SecurityUtil.getStpLogic(StpTypeEnum.DEFAULT.getText());
         stpLogic.login(sysUser.getId());

+ 3 - 0
nb-service/web-service/src/main/java/com/nb/web/service/system/entity/SysUser.java

@@ -201,6 +201,9 @@ public class SysUser extends TenantGenericEntity<Long,Long> {
     @TableField
     private Boolean isSys;
 
+    @TableField("密码是否需要修改")
+    private Boolean pswNeedReset;
+
     @Getter
     @TableField(value = "tenant_id",insertStrategy = FieldStrategy.NEVER,updateStrategy = FieldStrategy.NEVER,typeHandler = TenantNameHandler.class)
     private String tenantName;

+ 26 - 0
nb-service/web-service/src/main/java/com/nb/web/service/system/utils/PswUtils.java

@@ -0,0 +1,26 @@
+package com.nb.web.service.system.utils;
+
+
+/**
+ * @ClassName : PswUtils
+ * @Description :
+ * @Author : LF
+ * @Date: 2024年09月10日
+ */
+
+public class PswUtils {
+    /***
+     * 描述: 密码规则
+     *
+     * @param pwd 密码
+     * @return String
+     */
+    public static boolean validatePsw(String pwd) {
+        System.out.println(pwd);
+        String str = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\\W_!@#$%^&*`~()-+=]+$)(?![0-9\\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\\W_!@#$%^&*`~()-+=]{8,16}$";
+        if (!pwd.matches(str)) {
+            return false;
+        }
+        return true;
+    }
+}