Zelyanoth commited on
Commit
e484e19
·
1 Parent(s): b48b9dd
backend/services/auth_service.py CHANGED
@@ -42,7 +42,7 @@ def register_user(email: str, password: str) -> dict:
42
  # Email confirmation is required
43
  return {
44
  'success': True,
45
- 'message': 'Account created successfully! Please check your email for a confirmation link to activate your account.',
46
  'user': user.to_dict(),
47
  'email_confirmed': False,
48
  'requires_confirmation': True
@@ -97,7 +97,7 @@ def login_user(email: str, password: str, remember_me: bool = False) -> dict:
97
  if not response.user.email_confirmed_at:
98
  return {
99
  'success': False,
100
- 'message': 'Please confirm your email before logging in. Check your inbox for the confirmation email.',
101
  'requires_confirmation': True
102
  }
103
 
@@ -151,12 +151,12 @@ def login_user(email: str, password: str, remember_me: bool = False) -> dict:
151
  if 'invalid credentials' in error_str or 'unauthorized' in error_str:
152
  return {
153
  'success': False,
154
- 'message': 'Invalid email or password. Please check your credentials and try again.'
155
  }
156
  elif 'email not confirmed' in error_str or 'email not verified' in error_str:
157
  return {
158
  'success': False,
159
- 'message': 'Please confirm your email before logging in. Check your inbox for the confirmation email.',
160
  'requires_confirmation': True
161
  }
162
  elif 'user not found' in error_str:
 
42
  # Email confirmation is required
43
  return {
44
  'success': True,
45
+ 'message': 'Check your mail to confirm your account',
46
  'user': user.to_dict(),
47
  'email_confirmed': False,
48
  'requires_confirmation': True
 
97
  if not response.user.email_confirmed_at:
98
  return {
99
  'success': False,
100
+ 'message': 'Check your mail to confirm your account',
101
  'requires_confirmation': True
102
  }
103
 
 
151
  if 'invalid credentials' in error_str or 'unauthorized' in error_str:
152
  return {
153
  'success': False,
154
+ 'message': 'Password/email Incorrect'
155
  }
156
  elif 'email not confirmed' in error_str or 'email not verified' in error_str:
157
  return {
158
  'success': False,
159
+ 'message': 'Check your mail to confirm your account',
160
  'requires_confirmation': True
161
  }
162
  elif 'user not found' in error_str:
frontend/src/App.jsx CHANGED
@@ -197,17 +197,10 @@ function App() {
197
  }
198
  }, []); // Empty dependency array to run only once
199
 
200
- // Show loading state only while checking auth on initial load
201
- if (isCheckingAuth) {
202
- return (
203
- <div className="loading">
204
- <div className="auth-loading">
205
- <div className="spinner"></div>
206
- <p>Checking authentication...</p>
207
- </div>
208
- </div>
209
- );
210
- }
211
 
212
  return (
213
  <ErrorBoundary>
@@ -244,18 +237,28 @@ function App() {
244
  )}
245
 
246
  {/* Full-width layout without header/sidebar for Home/Auth/Callback */}
247
- {(!isAuthenticated || isAuthRoute || isCallbackRoute || location.pathname === '/') ? (
248
  <div className="content" id="main-content" tabIndex={-1}>
249
- <Routes>
250
- <Route path="/" element={
251
- <Suspense fallback={<div className="mobile-loading-optimized">Loading...</div>}>
252
- <Home />
253
- </Suspense>
254
- } />
255
- <Route path="/login" element={<Login />} />
256
- <Route path="/register" element={<Register />} />
257
- <Route path="/linkedin/callback" element={<LinkedInCallbackHandler />} />
258
- </Routes>
 
 
 
 
 
 
 
 
 
 
259
  </div>
260
  ) : (
261
  <>
 
197
  }
198
  }, []); // Empty dependency array to run only once
199
 
200
+ // Show a subtle auth checking indicator for protected routes while auth is being verified
201
+ // But don't block access to public routes
202
+ const isProtectedRoute = !isAuthRoute && !isCallbackRoute && location.pathname !== '/';
203
+ const showAuthChecking = isCheckingAuth && isProtectedRoute;
 
 
 
 
 
 
 
204
 
205
  return (
206
  <ErrorBoundary>
 
237
  )}
238
 
239
  {/* Full-width layout without header/sidebar for Home/Auth/Callback */}
240
+ {(showAuthChecking || !isAuthenticated || isAuthRoute || isCallbackRoute || location.pathname === '/') ? (
241
  <div className="content" id="main-content" tabIndex={-1}>
242
+ {showAuthChecking ? (
243
+ // Subtle auth checking indicator for protected routes
244
+ <div className="flex items-center justify-center min-h-screen">
245
+ <div className="text-center">
246
+ <div className="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-primary-500 mb-2"></div>
247
+ <p className="text-gray-600 text-sm">Checking authentication...</p>
248
+ </div>
249
+ </div>
250
+ ) : (
251
+ <Routes>
252
+ <Route path="/" element={
253
+ <Suspense fallback={<div className="mobile-loading-optimized">Loading...</div>}>
254
+ <Home />
255
+ </Suspense>
256
+ } />
257
+ <Route path="/login" element={<Login />} />
258
+ <Route path="/register" element={<Register />} />
259
+ <Route path="/linkedin/callback" element={<LinkedInCallbackHandler />} />
260
+ </Routes>
261
+ )}
262
  </div>
263
  ) : (
264
  <>
frontend/src/pages/Login.jsx CHANGED
@@ -146,7 +146,13 @@ const Login = () => {
146
  <svg className="w-4 h-4 sm:w-5 sm:h-5 text-red-500 flex-shrink-0 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
147
  <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
148
  </svg>
149
- <span className="text-red-700 text-xs sm:text-sm font-medium">{error}</span>
 
 
 
 
 
 
150
  </div>
151
  </div>
152
  )}
 
146
  <svg className="w-4 h-4 sm:w-5 sm:h-5 text-red-500 flex-shrink-0 mt-0.5" fill="currentColor" viewBox="0 0 20 20">
147
  <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
148
  </svg>
149
+ <span className="text-red-700 text-xs sm:text-sm font-medium">
150
+ {error.includes('Email or password is incorrect')
151
+ ? 'Password/email Incorrect'
152
+ : error.includes('verify your email')
153
+ ? 'Check your mail to confirm your account'
154
+ : error}
155
+ </span>
156
  </div>
157
  </div>
158
  )}
frontend/src/pages/Register.jsx CHANGED
@@ -144,7 +144,7 @@ const Register = () => {
144
  <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
145
  </svg>
146
  <span className="text-green-700 text-xs sm:text-sm font-medium">
147
- Account created successfully! Please check your email for a confirmation link to activate your account.
148
  </span>
149
  </div>
150
  </div>
@@ -362,6 +362,13 @@ const Register = () => {
362
  <span className="text-xs sm:text-sm">Create Account</span>
363
  )}
364
  </button>
 
 
 
 
 
 
 
365
  </form>
366
 
367
 
 
144
  <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
145
  </svg>
146
  <span className="text-green-700 text-xs sm:text-sm font-medium">
147
+ Check your mail to confirm your account
148
  </span>
149
  </div>
150
  </div>
 
362
  <span className="text-xs sm:text-sm">Create Account</span>
363
  )}
364
  </button>
365
+
366
+ {/* Confirmation Message */}
367
+ {!error && !showSuccess && (
368
+ <div className="text-center text-xs sm:text-sm text-gray-600">
369
+ After registration, please check your email to confirm your account.
370
+ </div>
371
+ )}
372
  </form>
373
 
374
 
frontend/src/store/reducers/authSlice.js CHANGED
@@ -465,9 +465,9 @@ const authSlice = createSlice({
465
  // Check for specific error types
466
  const errorMsg = errorPayload.message.toLowerCase();
467
  if (errorMsg.includes('email not confirmed') || errorMsg.includes('email not verified') || errorPayload.requires_confirmation) {
468
- errorMessage = 'Please verify your email before logging in. Check your inbox for the confirmation email.';
469
  } else if (errorMsg.includes('invalid credentials') || errorMsg.includes('invalid email') || errorMsg.includes('invalid password')) {
470
- errorMessage = 'Email or password is incorrect. Please try again.';
471
  } else if (errorMsg.includes('user not found')) {
472
  errorMessage = 'No account found with this email. Please check your email or register for a new account.';
473
  } else {
 
465
  // Check for specific error types
466
  const errorMsg = errorPayload.message.toLowerCase();
467
  if (errorMsg.includes('email not confirmed') || errorMsg.includes('email not verified') || errorPayload.requires_confirmation) {
468
+ errorMessage = 'Check your mail to confirm your account';
469
  } else if (errorMsg.includes('invalid credentials') || errorMsg.includes('invalid email') || errorMsg.includes('invalid password')) {
470
+ errorMessage = 'Password/email Incorrect';
471
  } else if (errorMsg.includes('user not found')) {
472
  errorMessage = 'No account found with this email. Please check your email or register for a new account.';
473
  } else {