use of io.jpom.model.data.UserModel in project Jpom by dromara.
the class UserService method hasDemoUser.
/**
* 是否包含 demo 账号
*
* @return true
*/
public boolean hasDemoUser() {
UserModel userModel = new UserModel();
userModel.setId(UserModel.DEMO_USER);
return super.exists(userModel);
}
use of io.jpom.model.data.UserModel in project Jpom by dromara.
the class UserService method closeSuperUserMfa.
/**
* 关闭超级管理账号 mfa
*
* @return 新密码
*/
public String closeSuperUserMfa() {
UserModel where = new UserModel();
where.setParent(UserModel.SYSTEM_ADMIN);
UserModel update = new UserModel();
update.setTwoFactorAuthKey(StrUtil.EMPTY);
int count = super.update(super.dataBeanToEntity(update), super.dataBeanToEntity(where));
return StrUtil.format("成功关闭超级管理员账号 mfa 验证:{} ", count);
}
use of io.jpom.model.data.UserModel in project Jpom by dromara.
the class UserService method generateSalt.
/**
* 生成 随机盐值
*
* @return 随机盐值
*/
public synchronized String generateSalt() {
while (true) {
String salt = RandomUtil.randomString(UserModel.SALT_LEN);
UserModel userModel = new UserModel();
userModel.setSalt(salt);
boolean exists = super.exists(userModel);
if (exists) {
continue;
}
return salt;
}
}
use of io.jpom.model.data.UserModel in project Jpom by dromara.
the class UserService method restSuperUserPwd.
/**
* 重置超级管理账号密码
*
* @return 新密码
*/
public String restSuperUserPwd() {
UserModel userModel = new UserModel();
userModel.setParent(UserModel.SYSTEM_ADMIN);
UserModel queryByBean = super.queryByBean(userModel);
if (queryByBean == null) {
return null;
}
String newPwd = RandomUtil.randomString(UserModel.SALT_LEN);
this.updatePwd(queryByBean.getId(), SecureUtil.sha1(newPwd));
return StrUtil.format("重置超级管理员账号密码成功,登录账号为:{} 新密码为:{}", queryByBean.getId(), newPwd);
}
use of io.jpom.model.data.UserModel in project Jpom by dromara.
the class UserService method updatePwd.
/**
* 修改密码
*
* @param id 账号ID
* @param newPwd 新密码
*/
public void updatePwd(String id, String newPwd) {
String salt = this.generateSalt();
UserModel userModel = UserModel.unLock(id);
// userModel.setId(id);
userModel.setSalt(salt);
userModel.setPassword(SecureUtil.sha1(newPwd + salt));
super.update(userModel);
}
Aggregations