ws
2024-11-25 36eacf7f2ab1ce7f0c40439b3ee6d13ecfcc5265
src/main/java/com/fzzy/sys/UserPR.java
@@ -59,14 +59,12 @@
            if (null == entity.getCreateDate()) {
                entity.setCreateDate(new Date());
            }
//            if (null == entity.getCompanyId()) {
//                entity.setCompanyId(ContextUtil.getCompanyId(true));
//            }
            //密码加密
            int salt = RandomUtils.nextInt(27);
            salt += 4;
            bCryptPasswordEncoder = new BCryptPasswordEncoder(salt);
            String password = bCryptPasswordEncoder.encode(entity.getPassword());
            BCryptPasswordEncoder encode = new BCryptPasswordEncoder();
            String password = encode.encode(entity.getPassword());
//            boolean b= bCryptPasswordEncoder.matches(entity.getPassword(),password);
            entity.setPassword(password);
            entity.setSalt(String.valueOf(salt));
@@ -98,11 +96,12 @@
     */
    @Expose
    public String resetPassword(SysUser entity) {
        //密码加密
        int salt = RandomUtils.nextInt(27);
        salt += 4;
        bCryptPasswordEncoder = new BCryptPasswordEncoder(salt);
        String password = bCryptPasswordEncoder.encode(Constant.DEFAULT_USER_PASSWORD);
        BCryptPasswordEncoder encode = new BCryptPasswordEncoder();
        String password = encode.encode(Constant.DEFAULT_USER_PASSWORD);
        entity.setPassword(password);
        entity.setSalt(String.valueOf(salt));
@@ -120,4 +119,9 @@
        return null;
    }
    public boolean checkPassword(String inputPwd, SysUser user) {
        BCryptPasswordEncoder encode = new BCryptPasswordEncoder();
        return encode.matches(inputPwd, user.getPassword());
    }
}