This commit is contained in:
xion 2025-03-30 12:48:14 +08:00
parent 0c36328ac3
commit 60c5a986ed
2 changed files with 5 additions and 2 deletions

View File

@ -47,7 +47,7 @@ export class User extends Model {
* @param uid * @param uid
* @returns * @returns
*/ */
async createToken(uid?: string, loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year', expand: any = {}) { async createToken(uid?: string, loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week', expand: any = {}) {
const { id, username, type } = this; const { id, username, type } = this;
const oauthUser: OauthUser = { const oauthUser: OauthUser = {
id, id,

View File

@ -58,7 +58,7 @@ export type UserExpand = {
} & StoreSetOpts; } & StoreSetOpts;
type StoreSetOpts = { type StoreSetOpts = {
loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year'; // 登陆类型 'default' | 'plugin' | 'month' | 'season' | 'year' loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week'; // 登陆类型 '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 'week':
expire = 7 * 24 * 60 * 60;
break;
case 'month': case 'month':
expire = 30 * 24 * 60 * 60; expire = 30 * 24 * 60 * 60;
break; break;