mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-08-18 08:27:14 +02:00
Initial open source release
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// handle not ok typical responses such as unauthenticated, renew password and such
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
/**
|
||||
* @param {import("./client").ApiResponse} apiResponse
|
||||
* @returns {import("./client").ApiResponse} apiResponse
|
||||
**/
|
||||
export const immediateResponseHandler = (apiResponse) => {
|
||||
// Unauthenticated move the user to the login page
|
||||
if (apiResponse.statusCode === 401) {
|
||||
goto('/login');
|
||||
window.location.reload();
|
||||
}
|
||||
// If the user must renew their password, move them to the renew password page
|
||||
if (apiResponse.statusCode === 400 && apiResponse.error === 'New password required') {
|
||||
goto('/login/reset-password');
|
||||
return;
|
||||
}
|
||||
return apiResponse;
|
||||
};
|
||||
Reference in New Issue
Block a user