fixed bug auth
This commit is contained in:
@@ -16,9 +16,10 @@ const errorServer = (response, notification, toastContainer) => {
|
||||
if (notification) errorServerToast(toastContainer);
|
||||
};
|
||||
|
||||
const errorClient = (response, notification, toastContainer) => {
|
||||
const errorClient = (response, notification, toastContainer, logout) => {
|
||||
switch (response.status) {
|
||||
case 401:
|
||||
logout()
|
||||
if (notification) errorUnauthorizedToast(toastContainer);
|
||||
break;
|
||||
case 422:
|
||||
@@ -50,11 +51,11 @@ const errorClient = (response, notification, toastContainer) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const errorResponse = (response, notification, toastContainer) => {
|
||||
export const errorResponse = (response, notification, toastContainer, logout) => {
|
||||
if (notification) toast.dismiss({ container: toastContainer });
|
||||
if (isServerError(response.status)) {
|
||||
errorServer(response, notification, toastContainer);
|
||||
} else if (isClientError(response.status)) {
|
||||
errorClient(response, notification, toastContainer);
|
||||
errorClient(response, notification, toastContainer, logout);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user