添加刷新令牌maxAge值

This commit is contained in:
Eamon-meng
2025-06-26 10:08:46 +08:00
parent b19b01f82c
commit 570a1ffa65

View File

@@ -23,6 +23,7 @@ export async function login(props: {
grant_type: 'password', grant_type: 'password',
login_type: 'phone_code', login_type: 'phone_code',
}) })
if (!result.success) { if (!result.success) {
return result return result
} }
@@ -38,6 +39,7 @@ export async function login(props: {
cookieStore.set('auth_refresh', data.refresh_token, { cookieStore.set('auth_refresh', data.refresh_token, {
httpOnly: true, httpOnly: true,
sameSite: 'strict', sameSite: 'strict',
maxAge: Number.MAX_SAFE_INTEGER,
}) })
return { return {
@@ -97,7 +99,9 @@ export async function refreshAuth() {
// 处理请求 // 处理请求
if (!resp.success) { if (!resp.success) {
cookie.delete('auth_refresh') if (resp.status === 401) {
cookie.delete('auth_refresh')
}
throw UnauthorizedError throw UnauthorizedError
} }