ADD Google OAuth login and logout functionality on frontend

This commit is contained in:
2025-08-11 15:16:47 +02:00
parent 662966f138
commit 0c11abc7b9
7 changed files with 113 additions and 44 deletions

View File

@@ -30,6 +30,23 @@ const login = async (GoogleToken: string): Promise<string> => {
return result.data.token;
}
const logout = async () => {
const response = await fetch(API_URL + '/api/v1/auth/logout', {
method: 'POST',
credentials: 'include'
});
if (!response.ok) {
throw new Error(`Logout failed: ${response.status}`);
}
const result: APIResponse = await response.json();
if (result.status === "error") {
throw new Error(`Logout failed: ${result.message}`);
}
}
/**
* Uploads a file to the backend.
* @param file - The file to upload.
@@ -233,6 +250,7 @@ const isThumbnailAvailable = async (id: number): Promise<boolean> => {
export {
login,
logout,
uploadFile,
editFile,
processFile,