Simplify auth system by removing throttling and mobile workarounds
All checks were successful
Build And Push Image / docker (push) Successful in 3m0s
All checks were successful
Build And Push Image / docker (push) Successful in 3m0s
- Remove session check throttling mechanism from useAuth composable - Eliminate forced auth check parameters throughout codebase - Replace window.location redirects with standard navigateTo() - Remove mobile-specific authentication handling and diagnostics - Move auth check to onMounted hook in login page - Clean up console logging for auth operations
This commit is contained in:
@@ -128,26 +128,6 @@ definePageMeta({
|
||||
// Use the auth composable
|
||||
const { user, login, loading: authLoading, error: authError, checkAuth } = useAuth();
|
||||
|
||||
// Import mobile utilities for enhanced debugging
|
||||
const { isMobileDevice, debugMobileLogin, runMobileDiagnostics } = await import('~/utils/mobile-utils');
|
||||
|
||||
// Check if user is already authenticated - prevent iOS Safari loops
|
||||
// Use forced check to ensure we get accurate authentication status
|
||||
const isAlreadyAuthenticated = await checkAuth(true);
|
||||
if (isAlreadyAuthenticated && user.value) {
|
||||
const redirectUrl = '/dashboard';
|
||||
|
||||
// Always use window.location for iOS Safari to prevent loops
|
||||
if (isMobileDevice()) {
|
||||
console.log('📱 Mobile browser detected, using window.location redirect');
|
||||
debugMobileLogin('Already authenticated redirect');
|
||||
// Use window.location.replace to avoid back button issues
|
||||
window.location.replace(redirectUrl);
|
||||
} else {
|
||||
await navigateTo(redirectUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// Reactive data
|
||||
const credentials = ref({
|
||||
username: '',
|
||||
@@ -204,12 +184,12 @@ const handleLogin = async () => {
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
// Handle redirect from the component using window.location for reliability
|
||||
// Handle redirect using standard Nuxt navigation
|
||||
console.log('🔄 Login successful, redirecting to:', result.redirectTo);
|
||||
const redirectUrl = result.redirectTo || '/dashboard';
|
||||
|
||||
// Use window.location for a reliable redirect
|
||||
window.location.href = redirectUrl;
|
||||
// Use standard navigation
|
||||
await navigateTo(redirectUrl);
|
||||
} else {
|
||||
loginError.value = result.error || 'Login failed. Please check your credentials and try again.';
|
||||
}
|
||||
@@ -225,8 +205,17 @@ const handlePasswordResetSuccess = (message: string) => {
|
||||
console.log('Password reset:', message);
|
||||
};
|
||||
|
||||
// Auto-focus username field on mount
|
||||
onMounted(() => {
|
||||
// Check auth and auto-focus on mount
|
||||
onMounted(async () => {
|
||||
// Check if user is already authenticated (client-side only)
|
||||
const isAuthenticated = await checkAuth();
|
||||
if (isAuthenticated && user.value) {
|
||||
console.log('🔄 User already authenticated, redirecting to dashboard');
|
||||
await navigateTo('/dashboard');
|
||||
return;
|
||||
}
|
||||
|
||||
// Auto-focus username field
|
||||
nextTick(() => {
|
||||
const usernameField = document.querySelector('input[type="text"]') as HTMLInputElement;
|
||||
if (usernameField) {
|
||||
|
||||
Reference in New Issue
Block a user