account lockout

This commit is contained in:
2025-02-09 13:21:57 +08:00
parent e7c92f252f
commit a43957a7c2
8 changed files with 199 additions and 14 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
);