jeecgboot/JeecgBoot · error · JeecgBootException

用户不是今天创建的,无法删除!

Error message

用户不是今天创建的,无法删除!

What it means

verifyCreateTimeAndPassword throws when the target user's createTime is not the same calendar day as today (DateUtils.isSameDay). Deletion is restricted to users created the same day — a safeguard allowing admins to immediately undo an erroneous same-day account creation, while preventing deletion of established accounts even by their creator.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java:945

    }

    /**
     * 验证创建时间和密码
     * 
     * @param sysUser
     * @param password
     */
    private void verifyCreateTimeAndPassword(SysUser sysUser,String password) {
        if(null == sysUser){
            throw new JeecgBootException("该用户不存在,无法删除!");
        }
        //step1 验证创建时间
        //当前登录用户
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        Date createTime = sysUser.getCreateTime();
        boolean sameDay = DateUtils.isSameDay(createTime, new Date());
        if(!sameDay){
            throw new JeecgBootException("用户不是今天创建的,无法删除!");
        }
        //step2 验证密码
        //获取admin的用户
        SysUser adminUser = userService.getById(user.getId());
        String passwordEncode = PasswordUtil.encrypt(adminUser.getUsername(), password, adminUser.getSalt());
        if(!passwordEncode.equals(adminUser.getPassword())){
            throw new JeecgBootException("您输入的密码不正确,无法删除该用户!");
        }
    }

    @Override
    public List<SysTenant> getTenantListByUserId(String userId) {
        return tenantMapper.getTenantListByUserId(userId);
    }

    @Override
    public void deleteUser(SysUser sysUser, Integer tenantId) {
        //被删除人的用户id

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Confirm deletion is intended for a same-day-created user; if the account is older, use the standard deactivation/disable flow instead.
  2. Verify server and database timezones align so isSameDay evaluates the correct calendar day (especially around midnight).
  3. If policy requires deleting an older account, escalate to a DB-level/logic-delete procedure with proper authorization.
  4. For imported users with backdated create_time, adjust expectations — they will not pass the same-day gate.

Example fix

// before
tenantService.deleteUserByPassword(targetUser, tenantId);

// after
if (!DateUtils.isSameDay(targetUser.getCreateTime(), new Date())) {
    return Result.error("仅可删除当日创建的用户;该用户创建于 " + targetUser.getCreateTime() + ",请改用禁用流程");
}
tenantService.deleteUserByPassword(targetUser, tenantId);
Defensive patterns

Strategy: validation

Validate before calling

if (!DateUtils.isSameDay(targetUser.getCreateTime(), new Date())) {
    return Result.error("仅当日创建的用户可删除,该用户创建于 " + targetUser.getCreateTime());
}

Try / catch

try {
    tenantService.deleteUserByPassword(targetUser, tenantId);
} catch (JeecgBootException e) {
    if (e.getMessage().contains("今天创建")) {
        return Result.error("该用户非当日创建,请改用禁用流程");
    }
    throw e;
}

Prevention

When it happens

Trigger: Attempting to delete a user whose sys_user.create_time falls on a previous day. Even if all other conditions (admin authority, resigned, no other orgs, is creator) pass, a non-today creation date blocks deletion.

Common situations: Trying to delete a user created days/weeks ago; timezone differences between the DB server and app server cause isSameDay to misjudge the day boundary; clock skew; the user was imported with a backdated create_time.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/2d5bf5e8ec8706fb. Report an issue: GitHub.