feat:
1. add APPUserController
This commit is contained in:
@@ -17,6 +17,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.mp.enums.StatusType;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.oauth2.exception.ExceptionCode;
|
||||
import org.springblade.core.oauth2.exception.OAuth2Exception;
|
||||
import org.springblade.core.oauth2.props.OAuth2Properties;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
@@ -44,6 +45,7 @@ import java.util.Objects;
|
||||
|
||||
import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD;
|
||||
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
|
||||
import static org.springblade.modules.auth.constant.BladeAuthConstant.INIT_PASSWD_VALUE;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
@@ -595,14 +597,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
||||
@Override
|
||||
public Boolean hasChangedPassword() {
|
||||
User user = getById(AuthUtil.getUserId());
|
||||
return user.getCreateTime() == user.getUpdateTime();
|
||||
Assert.notNull(user, ExceptionCode.INVALID_USER.getMessage());
|
||||
return !user.getPassword().equalsIgnoreCase(DigestUtil.encrypt(ParamCache.getValue(INIT_PASSWD_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changePassword(String password) {
|
||||
Assert.isTrue(StringUtil.isNotBlank(password), "无效密码");
|
||||
Assert.isTrue(StringUtil.isNotBlank(password), ExceptionCode.INVALID_USER_PASSWORD.getMessage());
|
||||
User user = getById(AuthUtil.getUserId());
|
||||
user.setPassword(SM2Util.decrypt(password, properties.getPublicKey(), properties.getPrivateKey()));
|
||||
user.setPassword(DigestUtil.encrypt(SM2Util.decrypt(password, properties.getPublicKey(), properties.getPrivateKey())));
|
||||
return updateById(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,21 @@ public class Sm2KeyGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("================ blade.oauth2 配置如下 =================");
|
||||
AsymmetricCipherKeyPair keyPair = SM2Util.generateKeyPair();
|
||||
// AsymmetricCipherKeyPair keyPair = SM2Util.generateKeyPair();
|
||||
// String publicKey = SM2Util.getPublicKeyString(keyPair);
|
||||
// String privateKey = SM2Util.getPrivateKeyString(keyPair);
|
||||
|
||||
String publicKey = "049a315b42a9fd789c321442185f0375fdd7686461fad1276e999a738700375ece22e8a343052ee6be0d1cba174adacaa875c4ffdd0a2b936df26c330f5815599a";
|
||||
String privateKey = "3d3713f75f9d91583360388428693ddbebd480b8141414b59655a6e6bbbaec15";
|
||||
|
||||
String phone = "13370065231";
|
||||
byte[] encryptedData = SM2Util.encrypt(phone, publicKey);
|
||||
String decryptedText = SM2Util.decrypt(encryptedData, privateKey);
|
||||
System.out.println("加密后: " + Hex.toHexString(encryptedData));
|
||||
System.out.println("解密后: " + decryptedText);
|
||||
String passwd = "Qq!123456";
|
||||
byte[] encryptedData = SM2Util.encrypt(passwd, publicKey);
|
||||
// String decryptedText = SM2Util.decrypt(encryptedData, privateKey);
|
||||
System.out.println("SM加密后: " + Hex.toHexString(encryptedData));
|
||||
// System.out.println("解密后: " + decryptedText);
|
||||
|
||||
String encryptPasswd = DigestUtil.encrypt(passwd);
|
||||
System.out.println("encrypt加密后: " + encryptPasswd);
|
||||
|
||||
|
||||
// System.out.println("#blade配置 \n" +
|
||||
|
||||
Reference in New Issue
Block a user