Changeset 22367db for components/Header.jsx
- Timestamp:
- 07/19/22 19:38:51 (2 years ago)
- Branches:
- main
- Children:
- 41d3f60
- Parents:
- faff334
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
components/Header.jsx
rfaff334 r22367db 11 11 import axios from 'axios'; 12 12 13 import { signOut, useSession } from 'next-auth/react'; 14 13 15 const Header = () => { 16 const { data: googleSession } = useSession(); 17 18 useEffect(() => { 19 if (googleSession && (!localStorage.CAESSINO_SESSION_ID || localStorage.CAESSINO_SESSION_ID === "")) { 20 axios.post(`/api/postgre`, { 21 action: 'login_via_google', 22 googleSession: googleSession, 23 }) 24 .then(res => { 25 if (res.data?.success) { 26 localStorage.CAESSINO_SESSION_ID = res.data?.session?.id; 27 28 dispatch(setPlayer({ 29 ...playerState.player, 30 username: res.data?.session?.username, 31 displayName: res.data?.session?.displayName, 32 credits: res.data?.session.credits, 33 session_id: res.data?.session?.id, 34 })); 35 36 dispatch(setStyle({ 37 ...styleState.style, 38 displayLoadingScreen: false, 39 displayLoginScreen: false, 40 loginScreenInfo: { 41 username: '', 42 password: '', 43 }, 44 notification: { 45 show: true, 46 text: 'Successfully logged in.', 47 status: 'success', 48 }, 49 inlineAlertText: '', 50 })); 51 } 52 }); 53 } 54 }, [googleSession]) 55 56 14 57 const dispatch = useDispatch(); 15 58 … … 50 93 credits: 0, 51 94 })) 95 signOut(); 52 96 } 53 97 })
Note:
See TracChangeset
for help on using the changeset viewer.