Skip to content

A self-hosted media server and file management system

fix: redundant double error handling in authAPI

aminnausin0cee4be71e14
diff --git a/resources/js/service/authAPI.ts b/resources/js/service/authAPI.ts
index 2d9886f5..b0e8c21b 100644
--- a/resources/js/service/authAPI.ts
+++ b/resources/js/service/authAPI.ts
@@ -9,12 +9,8 @@ export const getCSRF = async () => {
};
export const login = async (credentials: { email: string; password: string; remember: boolean }) => {
- try {
- await WEB.get(`/sanctum/csrf-cookie`);
- return API.post('/login', credentials);
- } catch (error) {
- throw error instanceof Error ? error : new Error(String(error));
- }
+ await getCSRF();
+ return API.post('/login', credentials);
};
export function recoverAccount(credentials: { email: string }) {
@@ -26,35 +22,21 @@ export function resetPassword(credentials: { token: string; email: string; passw
}
export const register = async (credentials: any) => {
- try {
- const response = await API.post('/register', credentials);
- return Promise.resolve(response);
- } catch (error) {
- throw error instanceof Error ? error : new Error(String(error));
- }
+ return API.post('/register', credentials);
};
export const logout = async () => {
- try {
- const response = await API.delete('/logout');
- const { data } = response;
- return Promise.resolve({ response: data });
- } catch (error) {
- throw error instanceof Error ? error : new Error(String(error));
- }
+ const response = await API.delete('/logout');
+ return Promise.resolve({ response: response.data });
};
-export const authenticate = async (token: string | null) => {
- try {
- return await API.get('/auth', {
- headers: {
- 'X-Skip-Toast': 'true',
- // Authorization: `bearer ${token}`, //This is the only place i use bearer but the entire spa app uses cookies
- },
- });
- } catch (error) {
- throw error instanceof Error ? error : new Error(String(error));
- }
+export const authenticate = async () => {
+ return API.get('/auth', {
+ headers: {
+ 'X-Skip-Toast': 'true',
+ // Authorization: `bearer ${token}`, //This is the only place i use bearer but the entire spa app uses cookies
+ },
+ });
};
export function changePassword(data: ChangePasswordRequest) {