MCPcopy Create free account
hub / github.com/AntiHub-Project/AntiHub / clearAuthCredentials

Function clearAuthCredentials

lib/api.ts:142–158  ·  view source on GitHub ↗

* 清除所有认证凭证

()

Source from the content-addressed store, hash-verified

140 * 清除所有认证凭证
141 */
142function clearAuthCredentials() {
143 if (typeof window === 'undefined') return;
144
145 // 清除 localStorage
146 localStorage.removeItem('access_token');
147 localStorage.removeItem('refresh_token');
148 localStorage.removeItem('token_expires_at');
149 localStorage.removeItem('user');
150
151 // 清除 cookies(设置过期时间为过去)
152 if (typeof document !== 'undefined') {
153 document.cookie = 'access_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
154 document.cookie = 'refresh_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
155 document.cookie = 'user=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
156 console.log('[clearAuthCredentials] 已清除所有认证凭证(localStorage + cookies)');
157 }
158}
159
160/**
161 * 刷新 Token

Callers 4

fetchWithAuthFunction · 0.85
logoutFunction · 0.85
generateImageFunction · 0.85
sendChatCompletionStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected