feat: 添加重置邀请码验证状态功能,并在退出登录时调用
This commit is contained in:
@ -4,6 +4,7 @@ import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
import { onTokenReceived, type UserInfo, clearUserInfo } from "./userService";
|
||||
import { getConfig } from "../config/settings";
|
||||
import { resetInvitationVerification } from "./apiClient";
|
||||
|
||||
/**
|
||||
* IC Coder Authentication Provider
|
||||
@ -142,13 +143,24 @@ export class ICCoderAuthenticationProvider
|
||||
const sessionIndex = this._sessions.findIndex((s) => s.id === sessionId);
|
||||
if (sessionIndex > -1) {
|
||||
const session = this._sessions[sessionIndex];
|
||||
|
||||
// 1. 先调用后端重置邀请码验证状态
|
||||
try {
|
||||
await resetInvitationVerification();
|
||||
console.log("[AuthProvider] 邀请码验证状态已重置");
|
||||
} catch (error) {
|
||||
console.warn("[AuthProvider] 重置邀请码验证状态失败,但继续退出流程:", error);
|
||||
// 即使失败也继续退出流程
|
||||
}
|
||||
|
||||
// 2. 清除本地 session
|
||||
this._sessions.splice(sessionIndex, 1);
|
||||
await this.saveSessions();
|
||||
|
||||
// 清除用户信息缓存
|
||||
// 3. 清除用户信息缓存
|
||||
await clearUserInfo();
|
||||
|
||||
// 触发会话变化事件
|
||||
// 4. 触发会话变化事件
|
||||
this._onDidChangeSessions.fire({
|
||||
added: [],
|
||||
removed: [session],
|
||||
|
||||
Reference in New Issue
Block a user