remove redirect (#182)

This commit is contained in:
vincanger 2024-06-20 16:41:47 +02:00 committed by GitHub
parent 8bd4de6676
commit ddff078d4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 13 deletions

View File

@ -0,0 +1,19 @@
--- template/app/src/client/auth/LoginPage.tsx
+++ opensaas-sh/app/src/client/auth/LoginPage.tsx
@@ -1,8 +1,15 @@
import { LoginForm } from 'wasp/client/auth';
-import { Link } from 'react-router-dom';
+import { Redirect, Link } from 'react-router-dom';
import { AuthWrapper } from './authWrapper';
export default function Login() {
+
+ const { data: user } = useAuth();
+
+ if (user) {
+ return <Redirect to='/demo-app' />;
+ }
+
return (
<AuthWrapper>
<LoginForm />

View File

@ -1,20 +1,8 @@
import { useAuth, LoginForm } from 'wasp/client/auth';
import { useHistory } from 'react-router-dom';
import { useEffect } from 'react';
import { LoginForm } from 'wasp/client/auth';
import { Link } from 'react-router-dom';
import { AuthWrapper } from './authWrapper';
export default function Login() {
const history = useHistory();
const { data: user } = useAuth();
useEffect(() => {
if (user) {
history.push('/');
}
}, [user, history]);
return (
<AuthWrapper>
<LoginForm />