diff --git a/.env b/.env new file mode 100644 index 0000000..d8dad5b --- /dev/null +++ b/.env @@ -0,0 +1 @@ +NEXT_PUBLIC_SERVER_ENDPOINT=http://localhost:3005 \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5ae128c --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +NEXT_PUBLIC_SERVER_ENDPOINT= \ No newline at end of file diff --git a/src/components/layouts/LandingPage.tsx b/src/components/layouts/LandingPage.tsx index 963c74b..aff9267 100644 --- a/src/components/layouts/LandingPage.tsx +++ b/src/components/layouts/LandingPage.tsx @@ -39,7 +39,7 @@ const LandingPage = ({ children }: IProps): ReactElement => { diff --git a/src/components/modules/Menu.tsx b/src/components/modules/Menu.tsx index 4aa12b5..f2bbf4d 100644 --- a/src/components/modules/Menu.tsx +++ b/src/components/modules/Menu.tsx @@ -32,7 +32,7 @@ const Menu: FunctionComponent = ({ links, logoutButton = false }: IProps const dispatch = useAppDispatch(); - const [closed, setClosed] = useState(true); + const [closed, setClosed] = useState(false); const handleClick = () => { removeCookie('user'); diff --git a/src/constants/adminMenu.tsx b/src/constants/adminMenu.tsx index be9548e..c793594 100644 --- a/src/constants/adminMenu.tsx +++ b/src/constants/adminMenu.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { UserCircleIcon, VideoCameraIcon, HomeIcon, UsersIcon } from '@heroicons/react/outline'; +import { HomeIcon, UsersIcon } from '@heroicons/react/outline'; const ADMIN_MENUS: IMenu = { title: 'Général', @@ -14,7 +14,7 @@ const ADMIN_MENUS: IMenu = { // { name: 'Rôles', path: '/admin/roles', icon: <>, active: false }, // { name: 'Vérification', path: '/admin/verificationTypes', icon: <>, active: false }, // { name: 'Spécification', path: '/admin/questionSpecifications', icon: <>, active: false }, - { name: 'Profile', path: '/admin/profile', icon: , active: false }, + // { name: 'Profile', path: '/admin/profile', icon: , active: false }, ], }; diff --git a/src/constants/professorMenu.tsx b/src/constants/professorMenu.tsx index 4679af8..e12b5ca 100644 --- a/src/constants/professorMenu.tsx +++ b/src/constants/professorMenu.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { HomeIcon, CalendarIcon, AcademicCapIcon, UserCircleIcon, VideoCameraIcon } from '@heroicons/react/outline'; +import { HomeIcon, CalendarIcon, AcademicCapIcon, VideoCameraIcon } from '@heroicons/react/outline'; const PROFESSOR_MENU: IMenu = { title: '', @@ -9,7 +9,7 @@ const PROFESSOR_MENU: IMenu = { { name: 'Accueil', path: '/professor', icon: , active: false }, { name: 'Événements', path: '/professor/events', icon: , active: false }, { name: 'Tests', path: '/professor/quizzes', icon: , active: false }, - { name: 'Profile', path: '/professor/profile', icon: , active: false }, + // { name: 'Profile', path: '/professor/profile', icon: , active: false }, { name: 'Direct', path: '/professor/direct', icon: , active: false }, ], }; diff --git a/src/constants/studentMenu.tsx b/src/constants/studentMenu.tsx index 729a4c4..72bec81 100644 --- a/src/constants/studentMenu.tsx +++ b/src/constants/studentMenu.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { HomeIcon, AcademicCapIcon, UserCircleIcon } from '@heroicons/react/outline'; +import { HomeIcon, AcademicCapIcon } from '@heroicons/react/outline'; const STUDENT_MENU: IMenu = { title: '', @@ -8,7 +8,7 @@ const STUDENT_MENU: IMenu = { links: [ { name: 'Accueil', path: '/student', icon: , active: false }, { name: 'Tests', path: '/student/quiz', icon: , active: false }, - { name: 'Profile', path: '/student/profile', icon: , active: false }, + // { name: 'Profile', path: '/student/profile', icon: , active: false }, ], }; diff --git a/src/hooks/useAuthentication.ts b/src/hooks/useAuthentication.ts index 1f1abcb..eef2f34 100644 --- a/src/hooks/useAuthentication.ts +++ b/src/hooks/useAuthentication.ts @@ -33,14 +33,18 @@ const useAuthentication = (permission: number, cbs?: (() => void)[]): IReturnPro const cookieToken = cookies.user; if (!cookieToken && !reduxToken) fail(); + console.log('Passed stage 1 (retrieved the cookie or redux token)'); if (cookieToken) { // Validate the token try { + console.log('Getting authentified by the token'); const { data: tokenValidation } = await database.post('/auth/validateToken', {}, getHeaders(cookieToken)); if (!tokenValidation.valid) fail(); if (tokenValidation.rolePermission !== permission) fail(); + console.log('Got authentified'); + // Store the token into redux dispatch(setToken(cookieToken)); diff --git a/src/pages/login.tsx b/src/pages/login.tsx index ca8bee4..fc0e572 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -52,6 +52,7 @@ const Login: FunctionComponent = () => { try { const { data } = await database.post('/auth/login', { username, password }); + console.log(data); setCookie('user', data.token, { path: '/', maxAge: 3600, sameSite: true }); @@ -67,7 +68,7 @@ const Login: FunctionComponent = () => {
- Connection + Connextion Mot de passe oublié ?