feat: implement account email mismatch error handling and improve user feedback in authentication flows

This commit is contained in:
Junyan Qin
2026-01-01 17:01:32 +08:00
parent 61f08f3218
commit 02e12cc1e4
10 changed files with 60 additions and 19 deletions

View File

@@ -753,7 +753,7 @@ export class BackendClient extends BaseHttpClient {
});
}
public bindSpaceAccount(
public async bindSpaceAccount(
code: string,
state: string,
): Promise<{
@@ -761,7 +761,17 @@ export class BackendClient extends BaseHttpClient {
user: string;
account_type: 'local' | 'space';
}> {
return this.post('/api/v1/user/bind-space', { code, state });
const response = await this.instance.post('/api/v1/user/bind-space', {
code,
state,
});
if (response.data.code !== 0) {
throw {
code: response.data.code,
msg: response.data.msg || 'Unknown error',
};
}
return response.data.data;
}
// ============ Space OAuth API (Redirect Flow) ============
@@ -778,10 +788,19 @@ export class BackendClient extends BaseHttpClient {
return this.get('/api/v1/user/space/authorize-url', params);
}
public exchangeSpaceOAuthCode(code: string): Promise<{
public async exchangeSpaceOAuthCode(code: string): Promise<{
token: string;
user: string;
}> {
return this.post('/api/v1/user/space/callback', { code });
const response = await this.instance.post('/api/v1/user/space/callback', {
code,
});
if (response.data.code !== 0) {
throw {
code: response.data.code,
msg: response.data.msg || 'Unknown error',
};
}
return response.data.data;
}
}