mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-04 22:13:21 +00:00
fixed TFA setting up and login redirect issue
This commit is contained in:
@@ -22,6 +22,7 @@ const Login = () => {
|
|||||||
const emailId = useId();
|
const emailId = useId();
|
||||||
const passwordId = useId();
|
const passwordId = useId();
|
||||||
const tokenId = useId();
|
const tokenId = useId();
|
||||||
|
const { login, setAuthState } = useAuth();
|
||||||
const [isSignupMode, setIsSignupMode] = useState(false);
|
const [isSignupMode, setIsSignupMode] = useState(false);
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
username: "",
|
username: "",
|
||||||
@@ -41,7 +42,6 @@ const Login = () => {
|
|||||||
const [signupEnabled, setSignupEnabled] = useState(false);
|
const [signupEnabled, setSignupEnabled] = useState(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { login, setAuthState } = useAuth();
|
|
||||||
|
|
||||||
// Check if signup is enabled
|
// Check if signup is enabled
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -130,9 +130,8 @@ const Login = () => {
|
|||||||
const response = await authAPI.verifyTfa(tfaUsername, tfaData.token);
|
const response = await authAPI.verifyTfa(tfaUsername, tfaData.token);
|
||||||
|
|
||||||
if (response.data?.token) {
|
if (response.data?.token) {
|
||||||
// Store token and user data
|
// Update AuthContext with the new authentication state
|
||||||
localStorage.setItem("token", response.data.token);
|
setAuthState(response.data.token, response.data.user);
|
||||||
localStorage.setItem("user", JSON.stringify(response.data.user));
|
|
||||||
|
|
||||||
// Redirect to dashboard
|
// Redirect to dashboard
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
|||||||
@@ -529,6 +529,7 @@ const Profile = () => {
|
|||||||
|
|
||||||
// TFA Tab Component
|
// TFA Tab Component
|
||||||
const TfaTab = () => {
|
const TfaTab = () => {
|
||||||
|
const verificationTokenId = useId();
|
||||||
const [setupStep, setSetupStep] = useState("status"); // 'status', 'setup', 'verify', 'backup-codes'
|
const [setupStep, setSetupStep] = useState("status"); // 'status', 'setup', 'verify', 'backup-codes'
|
||||||
const [verificationToken, setVerificationToken] = useState("");
|
const [verificationToken, setVerificationToken] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
|
|||||||
Reference in New Issue
Block a user