diff --git a/frontend/src/pages/Login.jsx b/frontend/src/pages/Login.jsx index 50e2d97..681df27 100644 --- a/frontend/src/pages/Login.jsx +++ b/frontend/src/pages/Login.jsx @@ -49,7 +49,7 @@ const Login = () => { try { const response = await authAPI.login(formData.username, formData.password) - + if (response.data.requiresTfa) { setRequiresTfa(true) setTfaUsername(formData.username) @@ -77,12 +77,12 @@ const Login = () => { try { const response = await authAPI.signup(formData.username, formData.email, formData.password) - + if (response.data && response.data.token) { // Store token and user data localStorage.setItem('token', response.data.token) localStorage.setItem('user', JSON.stringify(response.data.user)) - + // Redirect to dashboard navigate('/') } else { @@ -90,8 +90,8 @@ const Login = () => { } } catch (err) { console.error('Signup error:', err) - const errorMessage = err.response?.data?.error || - (err.response?.data?.errors && err.response.data.errors.length > 0 + const errorMessage = err.response?.data?.error || + (err.response?.data?.errors && err.response.data.errors.length > 0 ? err.response.data.errors.map(e => e.msg).join(', ') : err.message || 'Signup failed') setError(errorMessage) @@ -107,12 +107,12 @@ const Login = () => { try { const response = await authAPI.verifyTfa(tfaUsername, tfaData.token) - + if (response.data && response.data.token) { // Store token and user data localStorage.setItem('token', response.data.token) localStorage.setItem('user', JSON.stringify(response.data.user)) - + // Redirect to dashboard navigate('/') } else { @@ -172,7 +172,7 @@ const Login = () => {
- +

{isSignupMode ? 'Create PatchMon Account' : 'Sign in to PatchMon'} @@ -190,9 +190,6 @@ const Login = () => { {isSignupMode ? 'Username' : 'Username or Email'}
-
- -
{ className="appearance-none rounded-md relative block w-full pl-10 pr-3 py-2 border border-secondary-300 placeholder-secondary-500 text-secondary-900 focus:outline-none focus:ring-primary-500 focus:border-primary-500 focus:z-10 sm:text-sm" placeholder={isSignupMode ? "Enter your username" : "Enter your username or email"} /> +
+ +

@@ -212,9 +216,6 @@ const Login = () => { Email
-
- -
{ className="appearance-none rounded-md relative block w-full pl-10 pr-3 py-2 border border-secondary-300 placeholder-secondary-500 text-secondary-900 focus:outline-none focus:ring-primary-500 focus:border-primary-500 focus:z-10 sm:text-sm" placeholder="Enter your email" /> +
+ +
)} @@ -234,9 +242,6 @@ const Login = () => { Password
-
- -
{ className="appearance-none rounded-md relative block w-full pl-10 pr-10 py-2 border border-secondary-300 placeholder-secondary-500 text-secondary-900 focus:outline-none focus:ring-primary-500 focus:border-primary-500 focus:z-10 sm:text-sm" placeholder="Enter your password" /> -
+
+ +
+
@@ -267,7 +279,7 @@ const Login = () => { {error && (
- +

{error}

@@ -311,7 +323,7 @@ const Login = () => {
- +

Two-Factor Authentication @@ -343,7 +355,7 @@ const Login = () => { {error && (
- +

{error}

@@ -370,9 +382,9 @@ const Login = () => {