set default for expire to 7 days

This commit is contained in:
xion 2025-04-02 09:54:53 +08:00
parent 162d4c72b4
commit 0a72db7771

View File

@ -58,7 +58,7 @@ export type UserExpand = {
} & StoreSetOpts; } & StoreSetOpts;
type StoreSetOpts = { type StoreSetOpts = {
loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week'; // 登陆类型 'default' | 'plugin' | 'month' | 'season' | 'year' loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week' | 'day'; // 登陆类型 'default' | 'plugin' | 'month' | 'season' | 'year'
expire?: number; // 过期时间,单位为秒 expire?: number; // 过期时间,单位为秒
hasRefreshToken?: boolean; hasRefreshToken?: boolean;
[key: string]: any; [key: string]: any;
@ -137,6 +137,9 @@ export class RedisTokenStore implements Store<OauthUser> {
let expire = opts?.expire; let expire = opts?.expire;
if (!expire) { if (!expire) {
switch (opts.loginType) { switch (opts.loginType) {
case 'day':
expire = 24 * 60 * 60;
break;
case 'week': case 'week':
expire = 7 * 24 * 60 * 60; expire = 7 * 24 * 60 * 60;
break; break;
@ -147,7 +150,7 @@ export class RedisTokenStore implements Store<OauthUser> {
expire = 90 * 24 * 60 * 60; expire = 90 * 24 * 60 * 60;
break; break;
default: default:
expire = 25 * 60 * 60; // 默认过期时间为25小时 expire = 7 * 24 * 60 * 60; // 默认过期时间为7天
} }
} else { } else {
expire = Math.min(expire, 60 * 60 * 24 * 30, 60 * 60 * 24 * 90); // 默认的过期时间最大为90天 expire = Math.min(expire, 60 * 60 * 24 * 30, 60 * 60 * 24 * 90); // 默认的过期时间最大为90天