@Override
    public Integer update(UserRequest request, String currentUser) {
        LOGGER.debug("begin to update user info={} by {}", request, currentUser);
        Preconditions.expectNotNull(request, "Userinfo cannot be null");
        Preconditions.expectNotNull(request.getId(), "User id cannot be null");

        // Whether the current user is a manager
        UserEntity currentUserEntity = userMapper.selectByName(currentUser);
        String updateName = request.getName();
        boolean isAdmin = Objects.equals(TenantUserTypeEnum.TENANT_ADMIN.getCode(), currentUserEntity.getAccountType());
        Preconditions.expectTrue(isAdmin || Objects.equals(updateName, currentUser),
                "You are not a manager and do not have permission to update other users");

        // manager cannot set himself as an ordinary
        boolean managerToOrdinary = isAdmin
                && Objects.equals(TenantUserTypeEnum.TENANT_OPERATOR.getCode(), request.getAccountType())
                && Objects.equals(currentUser, updateName);
        Preconditions.expectFalse(managerToOrdinary, "You are a manager and you cannot change to an ordinary user");

        // target username must not exist
        UserEntity updateUserEntity = userMapper.selectById(request.getId());
        Preconditions.expectNotNull(updateUserEntity, "User not exists with id=" + request.getId());
        String errMsg = String.format("user has already updated with username=%s, reqVersion=%s, storedVersion=%s",
                updateName, request.getVersion(), updateUserEntity.getVersion());
        if (!Objects.equals(updateUserEntity.getVersion(), request.getVersion())) {
            LOGGER.error(errMsg);
            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
        }

        UserEntity targetUserEntity = userMapper.selectByName(updateName);
        Preconditions.expectTrue(
                Objects.isNull(targetUserEntity)
                        || Objects.equals(targetUserEntity.getName(), updateUserEntity.getName()),
                "Username [" + updateName + "] already exists");

        // if the current user is not a manager, needs to check the password before updating user info
        if (!isAdmin) {
            String oldPassword = request.getPassword();
            String oldPasswordHash = SHAUtils.encrypt(oldPassword);
            Preconditions.expectTrue(oldPasswordHash.equals(updateUserEntity.getPassword()), "Old password is wrong");
            Integer validDays = DateUtils.getValidDays(updateUserEntity.getCreateTime(), updateUserEntity.getDueDate());
            Preconditions.expectTrue((request.getValidDays() <= validDays),
                    "Ordinary users are not allowed to add valid days");
            Preconditions.expectTrue(Objects.equals(updateUserEntity.getAccountType(), request.getAccountType()),
                    "Ordinary users are not allowed to update account type");
        }

        // update password
        if (!StringUtils.isBlank(request.getNewPassword())) {
            String newPasswordHash = SHAUtils.encrypt(request.getNewPassword());
            updateUserEntity.setPassword(newPasswordHash);
        }
        updateUserEntity.setDueDate(DateUtils.getExpirationDate(request.getValidDays()));
        updateUserEntity.setAccountType(request.getAccountType());
        updateUserEntity.setName(updateName);
        updateUserEntity.setExtParams(request.getExtParams());

        int rowCount = userMapper.updateByPrimaryKeySelective(updateUserEntity);
        if (rowCount != InlongConstants.AFFECTED_ONE_ROW) {
            LOGGER.error(errMsg);
            throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED);
        }
        LOGGER.debug("success to update user info={} by {}", request, currentUser);
        return updateUserEntity.getId();
    }
locked time, the unit is minute
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/UserServiceImpl.java