Skip to content

Commit

Permalink
⚙️ Production settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas committed Mar 9, 2023
1 parent 5e79727 commit ab32667
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_SERVER_ENDPOINT=http://localhost:3005
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_SERVER_ENDPOINT=<NEXT_PUBLIC_SERVER_ENDPOINT>
2 changes: 1 addition & 1 deletion src/components/layouts/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const LandingPage = ({ children }: IProps): ReactElement => {

<Link href="/login" passHref={true}>
<Button type="black" full={false}>
Connection
Connexion
</Button>
</Link>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Menu: FunctionComponent<IProps> = ({ links, logoutButton = false }: IProps

const dispatch = useAppDispatch();

const [closed, setClosed] = useState(true);
const [closed, setClosed] = useState(false);

const handleClick = () => {
removeCookie('user');
Expand Down
4 changes: 2 additions & 2 deletions src/constants/adminMenu.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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: <UserCircleIcon className="w-6 h-6" />, active: false },
// { name: 'Profile', path: '/admin/profile', icon: <UserCircleIcon className="w-6 h-6" />, active: false },
],
};

Expand Down
4 changes: 2 additions & 2 deletions src/constants/professorMenu.tsx
Original file line number Diff line number Diff line change
@@ -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: '',
Expand All @@ -9,7 +9,7 @@ const PROFESSOR_MENU: IMenu = {
{ name: 'Accueil', path: '/professor', icon: <HomeIcon className="w-6 h-6" />, active: false },
{ name: 'Événements', path: '/professor/events', icon: <CalendarIcon className="w-6 h-6" />, active: false },
{ name: 'Tests', path: '/professor/quizzes', icon: <AcademicCapIcon className="w-6 h-6" />, active: false },
{ name: 'Profile', path: '/professor/profile', icon: <UserCircleIcon className="w-6 h-6" />, active: false },
// { name: 'Profile', path: '/professor/profile', icon: <UserCircleIcon className="w-6 h-6" />, active: false },
{ name: 'Direct', path: '/professor/direct', icon: <VideoCameraIcon className="h-6 w-6" />, active: false },
],
};
Expand Down
4 changes: 2 additions & 2 deletions src/constants/studentMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';

import { HomeIcon, AcademicCapIcon, UserCircleIcon } from '@heroicons/react/outline';
import { HomeIcon, AcademicCapIcon } from '@heroicons/react/outline';

const STUDENT_MENU: IMenu = {
title: '',

links: [
{ name: 'Accueil', path: '/student', icon: <HomeIcon className="w-6 h-6" />, active: false },
{ name: 'Tests', path: '/student/quiz', icon: <AcademicCapIcon className="w-6 h-6" />, active: false },
{ name: 'Profile', path: '/student/profile', icon: <UserCircleIcon className="h-6 w-6" />, active: false },
// { name: 'Profile', path: '/student/profile', icon: <UserCircleIcon className="h-6 w-6" />, active: false },
],
};

Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
3 changes: 2 additions & 1 deletion src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -67,7 +68,7 @@ const Login: FunctionComponent = () => {
<Form onSubmit={handleSubmit}>
<FormGroup>
<Col>
<Title>Connection</Title>
<Title>Connextion</Title>
<Route to="/password-lost">Mot de passe oublié ?</Route>
</Col>

Expand Down

1 comment on commit ab32667

@vercel
Copy link

@vercel vercel bot commented on ab32667 Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.