mirror of
https://github.com/nocobase/nocobase.git
synced 2026-10-28 03:54:28 +08:00
Merge branch 'next' into develop
This commit is contained in:
@@ -32,5 +32,5 @@ export interface ITokenControlService {
|
||||
setConfig(config: TokenPolicyConfig): Promise<any>;
|
||||
renew(jti: string): Promise<{ jti: string; issuedTime: EpochTimeStamp }>;
|
||||
add({ userId }: { userId: number }): Promise<TokenInfo>;
|
||||
removeSessionExpiredTokens(userId: number): Promise<void>;
|
||||
removeSessionExpiredTokens(userId: number): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Cache } from '@nocobase/cache';
|
||||
import { randomUUID } from 'crypto';
|
||||
import ms from 'ms';
|
||||
import Application from '@nocobase/server';
|
||||
import Database, { Repository } from '@nocobase/database';
|
||||
import Database, { Repository, Op } from '@nocobase/database';
|
||||
import {
|
||||
issuedTokensCollectionName,
|
||||
tokenPolicyCollectionName,
|
||||
@@ -72,13 +72,13 @@ export class TokenController implements TokenControlService {
|
||||
|
||||
async removeSessionExpiredTokens(userId: number) {
|
||||
const config = await this.getConfig();
|
||||
const issuedTokenRepo = this.app.db.getRepository(issuedTokensCollectionName);
|
||||
const model = this.app.db.getModel(issuedTokensCollectionName);
|
||||
const currTS = Date.now();
|
||||
return issuedTokenRepo.destroy({
|
||||
filter: {
|
||||
userId: userId,
|
||||
return model.destroy({
|
||||
where: {
|
||||
userId,
|
||||
signInTime: {
|
||||
$lt: currTS - config.sessionExpirationTime,
|
||||
[Op.lt]: currTS - config.sessionExpirationTime,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user