Fix: Redirect to dashboard after login
Adjusted the login flow to redirect users to the dashboard upon successful authentication, instead of the landing page. This ensures users are directed to the application's core functionality after logging in.
This commit is contained in:
parent
749624e7a4
commit
6809553751
12
src/App.tsx
12
src/App.tsx
@ -34,19 +34,13 @@ function App() {
|
|||||||
{/* Landing page - só mostra se não estiver logado */}
|
{/* Landing page - só mostra se não estiver logado */}
|
||||||
<Route
|
<Route
|
||||||
path="/"
|
path="/"
|
||||||
element={isLoggedIn ? (
|
element={isLoggedIn ? <Navigate to="/dashboard" replace /> : <Landing />}
|
||||||
<ProtectedRoute>
|
|
||||||
<Suspense fallback={<div className="flex items-center justify-center min-h-screen">Carregando...</div>}>
|
|
||||||
<Dashboard />
|
|
||||||
</Suspense>
|
|
||||||
</ProtectedRoute>
|
|
||||||
) : <Landing />}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Auth route */}
|
{/* Auth route - redireciona para dashboard se já estiver logado */}
|
||||||
<Route
|
<Route
|
||||||
path="/auth"
|
path="/auth"
|
||||||
element={isLoggedIn ? <Navigate to="/" replace /> : <Auth />}
|
element={isLoggedIn ? <Navigate to="/dashboard" replace /> : <Auth />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Email confirmation route */}
|
{/* Email confirmation route */}
|
||||||
|
|||||||
@ -36,7 +36,8 @@ const LoginForm = ({ isLoading, setIsLoading }: LoginFormProps) => {
|
|||||||
toast.success("Login realizado com sucesso", {
|
toast.success("Login realizado com sucesso", {
|
||||||
description: "Bem-vindo de volta!"
|
description: "Bem-vindo de volta!"
|
||||||
});
|
});
|
||||||
navigate('/');
|
// Redirecionar para o dashboard após login bem-sucedido
|
||||||
|
navigate('/dashboard');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import { Link, useLocation } from 'react-router-dom';
|
|||||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Boxes } from "@/components/ui/background-boxes";
|
import { Boxes } from "@/components/ui/background-boxes";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { ArrowLeft } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import LoginForm from '@/components/auth/LoginForm';
|
import LoginForm from '@/components/auth/LoginForm';
|
||||||
import RegisterForm from '@/components/auth/RegisterForm';
|
import RegisterForm from '@/components/auth/RegisterForm';
|
||||||
@ -36,6 +38,14 @@ const Auth = () => {
|
|||||||
|
|
||||||
<Boxes />
|
<Boxes />
|
||||||
|
|
||||||
|
{/* Botão para voltar à landing page */}
|
||||||
|
<Link to="/" className="absolute top-4 left-4 z-30">
|
||||||
|
<Button variant="ghost" size="sm" className="text-white hover:bg-white/10">
|
||||||
|
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||||
|
Voltar
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
|
||||||
<Card className="w-full max-w-md relative z-20 bg-white/95 backdrop-blur-sm border-white/20">
|
<Card className="w-full max-w-md relative z-20 bg-white/95 backdrop-blur-sm border-white/20">
|
||||||
<CardHeader className="space-y-1 text-center">
|
<CardHeader className="space-y-1 text-center">
|
||||||
<div className="flex items-center justify-center space-x-2 mb-4">
|
<div className="flex items-center justify-center space-x-2 mb-4">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user