mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 16:37:26 +00:00
fix(oauth): enhance error handling and transaction management for OAuth user creation and binding
- Improve error handling in DeleteCustomOAuthProvider to log and return errors when fetching binding counts. - Refactor user creation and OAuth binding logic to use transactions for atomic operations, ensuring data integrity. - Add unique constraints to UserOAuthBinding model to prevent duplicate bindings. - Enhance GitHub OAuth provider error logging for non-200 responses. - Update AccountManagement component to provide clearer error messages on API failures.
This commit is contained in:
@@ -107,9 +107,11 @@ const AccountManagement = ({
|
||||
const res = await API.get('/api/user/oauth/bindings');
|
||||
if (res.data.success) {
|
||||
setCustomOAuthBindings(res.data.data || []);
|
||||
} else {
|
||||
showError(res.data.message || t('获取绑定信息失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
// ignore
|
||||
showError(error.response?.data?.message || error.message || t('获取绑定信息失败'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,7 +133,7 @@ const AccountManagement = ({
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
showError(t('操作失败'));
|
||||
showError(error.response?.data?.message || error.message || t('操作失败'));
|
||||
} finally {
|
||||
setCustomOAuthLoading((prev) => ({ ...prev, [providerId]: false }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user