fixed TFA setting up and login redirect issue

This commit is contained in:
Muhammad Ibrahim
2025-10-01 09:08:27 +01:00
parent 5d8a1e71d6
commit 0742c4b05c
2 changed files with 4 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ const Login = () => {
const emailId = useId();
const passwordId = useId();
const tokenId = useId();
const { login, setAuthState } = useAuth();
const [isSignupMode, setIsSignupMode] = useState(false);
const [formData, setFormData] = useState({
username: "",
@@ -41,7 +42,6 @@ const Login = () => {
const [signupEnabled, setSignupEnabled] = useState(false);
const navigate = useNavigate();
const { login, setAuthState } = useAuth();
// Check if signup is enabled
useEffect(() => {
@@ -130,9 +130,8 @@ const Login = () => {
const response = await authAPI.verifyTfa(tfaUsername, tfaData.token);
if (response.data?.token) {
// Store token and user data
localStorage.setItem("token", response.data.token);
localStorage.setItem("user", JSON.stringify(response.data.user));
// Update AuthContext with the new authentication state
setAuthState(response.data.token, response.data.user);
// Redirect to dashboard
navigate("/");

View File

@@ -529,6 +529,7 @@ const Profile = () => {
// TFA Tab Component
const TfaTab = () => {
const verificationTokenId = useId();
const [setupStep, setSetupStep] = useState("status"); // 'status', 'setup', 'verify', 'backup-codes'
const [verificationToken, setVerificationToken] = useState("");
const [password, setPassword] = useState("");