update modules/core: mod 2 files

This commit is contained in:
jack ning
2025-07-20 15:42:31 +08:00
parent 367405dcdc
commit ab233e5cbb
2 changed files with 9 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-05-08 11:22:07
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-07-10 10:23:36
* @LastEditTime: 2025-07-20 15:39:29
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
@@ -87,7 +87,7 @@ public class TokenEntity extends BaseEntity {
// 验证token是否有效
public Boolean isValid() {
return !revoked && !isDeleted() && expiresAt.isAfter(BdDateUtils.now());
return !revoked && !isDeleted() && expiresAt != null && expiresAt.isAfter(BdDateUtils.now());
}
// 撤销token

View File

@@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2025-05-22 15:42:28
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-07-17 12:26:45
* @LastEditTime: 2025-07-20 15:42:31
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
* Please be aware of the BSL license restrictions before installing Bytedesk IM
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
@@ -99,15 +99,17 @@ public class TokenRestService extends BaseRestService<TokenEntity, TokenRequest,
public TokenResponse create(TokenRequest request) {
TokenEntity entity = modelMapper.map(request, TokenEntity.class);
entity.setUid(uidUtils.getUid());
//
// 统一设置过期时间如果请求中没有设置过期时间则使用JWT配置的过期时间
if (entity.getExpiresAt() == null) {
entity.setExpiresAt(calculateExpirationTime(request.getChannel()));
}
TokenEntity savedEntity = save(entity);
if (savedEntity == null) {
throw new RuntimeException("Create token failed");
}
// 手动将实体放入缓存
// cacheToken(savedEntity);
return convertToResponse(savedEntity);
}