Search in sources :

Example 6 with UserModel

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);
}
Also used : UserModel(io.jpom.model.data.UserModel)

Example 7 with 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);
}
Also used : UserModel(io.jpom.model.data.UserModel)

Example 8 with UserModel

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;
    }
}
Also used : UserModel(io.jpom.model.data.UserModel)

Example 9 with UserModel

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);
}
Also used : UserModel(io.jpom.model.data.UserModel)

Example 10 with UserModel

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);
}
Also used : UserModel(io.jpom.model.data.UserModel)

Aggregations

UserModel (io.jpom.model.data.UserModel)66 JSONObject (com.alibaba.fastjson.JSONObject)17 MethodFeature (io.jpom.permission.MethodFeature)15 ClassFeature (io.jpom.permission.ClassFeature)14 Feature (io.jpom.permission.Feature)14 NodeModel (io.jpom.model.data.NodeModel)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 NotLogin (io.jpom.common.interceptor.NotLogin)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 UserService (io.jpom.service.user.UserService)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 StrUtil (cn.hutool.core.util.StrUtil)4 Entity (cn.hutool.db.Entity)4 JSONArray (com.alibaba.fastjson.JSONArray)4 BuildInfoModel (io.jpom.model.data.BuildInfoModel)4 List (java.util.List)4 JsonMessage (cn.jiangzeyin.common.JsonMessage)3 BaseServerController (io.jpom.common.BaseServerController)3 WorkspaceModel (io.jpom.model.data.WorkspaceModel)3 UserLoginDto (io.jpom.model.dto.UserLoginDto)3