account lockout
This commit is contained in:
@@ -27,8 +27,8 @@ export default function LoginView({ onSignup }: { onSignup: () => void }) {
|
||||
try {
|
||||
const response = await http.post("/User/login", loginRequest);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new Error("Login failed");
|
||||
if (response.status === 401) {
|
||||
throw new Error("Invalid email or password.");
|
||||
}
|
||||
|
||||
const { token } = response.data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect, useCallback } from "react";
|
||||
import { ToastContainer, toast } from "react-toastify";
|
||||
import { toast } from "react-toastify";
|
||||
import "react-toastify/dist/ReactToastify.css";
|
||||
|
||||
interface SessionTimeoutProps {
|
||||
@@ -47,11 +47,7 @@ const SessionTimeout: React.FC<SessionTimeoutProps> = ({
|
||||
return () => clearInterval(interval);
|
||||
}, [lastActivityTime, timeout, onLogout, notified]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ToastContainer />
|
||||
</>
|
||||
);
|
||||
return <></>;
|
||||
};
|
||||
|
||||
export default SessionTimeout;
|
||||
|
||||
@@ -33,10 +33,10 @@ http.interceptors.response.use(
|
||||
function (error) {
|
||||
// Any status codes that falls outside the range of 2xx cause this function to trigger
|
||||
// Do something with response error
|
||||
if (error.response.status === 401 || error.response.status === 403) {
|
||||
localStorage.clear();
|
||||
window.location.assign("/error");
|
||||
}
|
||||
// if (error.response.status === 401 || error.response.status === 403) {
|
||||
// localStorage.clear();
|
||||
// window.location.assign("/error");
|
||||
// }
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user