diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx
index 1be39f6..3894f8c 100644
--- a/src/pages/Auth.tsx
+++ b/src/pages/Auth.tsx
@@ -1,20 +1,24 @@
import { useState } from "react"
-import { logout, signInWithEmail, signInWithGoogle } from "../services/authentication"
+import { logout, signIn, signInWithGoogle } from "../services/authentication"
import { Toast } from "../components/Toast"
import { toast } from "react-toastify"
-export const Auth = () => {
- const [email, setEmail] = useState("")
- const [password, setPassword] = useState("")
+type AuthProps = {
+ onSignIn: () => void
+}
+
+export const Auth = (props: AuthProps) => {
const [name, setName] = useState("")
- const handleSignInWithEmail = (email: string, name: string, password: string) => {
- signInWithEmail(email, name, password).then((response) => {
+ const handleSignIn = (name: string) => {
+ signIn(name).then((response) => {
if (response.success) {
toast.success("Connexion reussie")
} else {
toast.error("Erreur lors de la connexion")
}
+
+ props.onSignIn()
})
}
@@ -25,6 +29,8 @@ export const Auth = () => {
} else {
toast.error("Erreur lors de la connexion")
}
+
+ props.onSignIn()
})
}
@@ -33,66 +39,39 @@ export const Auth = () => {
}
return (
-
-
-
-
-
-
- setName(e.target.value)}
- />
-
-
-
- setEmail(e.target.value)}
- />
-
-
-
- setPassword(e.target.value)}
- />
-
-
-
-
+
+
+
+
+
+ setName(e.target.value)}
+ />
+
+
+
+
-
ou
+
ou
-
+
-
+
diff --git a/src/pages/game/GameController.tsx b/src/pages/game/GameController.tsx
index dbf547d..0ea48a6 100644
--- a/src/pages/game/GameController.tsx
+++ b/src/pages/game/GameController.tsx
@@ -10,9 +10,11 @@ import { LobbyRoom } from "./LobbyRoom"
import { toast } from "react-toastify"
import { Toast } from "../../components/Toast"
import { LoadingPage } from "../../components/LoadingPage"
+import { Auth } from "../Auth"
export const GameController = () => {
const { gameId } = useParams()
+ const [user, setUser] = useState(getUserInfo())
const [gameState, setGameState] = useState(GameState.WAITING)
const [game, setGame] = useState({} as Game)
const [isLoading, setIsLoading] = useState(false)
@@ -98,6 +100,16 @@ export const GameController = () => {
})
}
+ if (!user.isAuth) {
+ return (
+
{
+ setUser(getUserInfo())
+ }}
+ />
+ )
+ }
+
return (
{gameState === GameState.WAITING ? (