mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-22 01:43:29 +01:00
Update token management again
This commit is contained in:
@@ -122,13 +122,11 @@ export class SQLiteSmapiTokenStore implements SmapiTokenStore {
|
||||
const smapiToken = tokens[tokenKey];
|
||||
if (smapiToken) {
|
||||
const verifyResult = smapiAuthTokens.verify(smapiToken);
|
||||
// Only delete if token verification fails with InvalidTokenError
|
||||
// Do NOT delete ExpiredTokenError as those can still be refreshed
|
||||
if (E.isLeft(verifyResult)) {
|
||||
const error = verifyResult.left;
|
||||
// Only delete invalid tokens, not expired ones (which can be refreshed)
|
||||
if (error._tag === 'InvalidTokenError') {
|
||||
logger.debug(`Deleting invalid token from SQLite store`);
|
||||
// Delete both invalid and expired tokens to prevent accumulation
|
||||
if (error._tag === 'InvalidTokenError' || error._tag === 'ExpiredTokenError') {
|
||||
logger.debug(`Deleting ${error._tag} token from SQLite store`);
|
||||
this.delete(tokenKey);
|
||||
deletedCount++;
|
||||
}
|
||||
@@ -137,7 +135,7 @@ export class SQLiteSmapiTokenStore implements SmapiTokenStore {
|
||||
}
|
||||
|
||||
if (deletedCount > 0) {
|
||||
logger.info(`Cleaned up ${deletedCount} invalid token(s) from SQLite store`);
|
||||
logger.info(`Cleaned up ${deletedCount} token(s) from SQLite store`);
|
||||
}
|
||||
|
||||
return deletedCount;
|
||||
|
||||
Reference in New Issue
Block a user