introduce a logout page and the navbar
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/components/logout.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/components/logout.tsx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| import React, { useContext } from 'react'; | ||||
| import { useNavigate } from 'react-router-dom'; | ||||
| import { AuthContext } from '../contexts'; | ||||
|  | ||||
| export const Logout: React.FC = () => { | ||||
|   const context = useContext(AuthContext); | ||||
|   const navigate = useNavigate(); | ||||
|  | ||||
|   context.setAuth({ | ||||
|     valid: false, | ||||
|     user: { | ||||
|       vatsimId: '', | ||||
|       fullName: '', | ||||
|       administrator: false, | ||||
|       airportConfigurationAccess: [], | ||||
|     }, | ||||
|   }); | ||||
|   sessionStorage.removeItem('token'); | ||||
|   navigate('/'); | ||||
|  | ||||
|   return <></>; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user