mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Deplacement du JWT dans le back
This commit is contained in:
@ -25,8 +25,8 @@ import {
|
||||
FE_ADMIN_SETTINGS_URL
|
||||
} from '@/utils/Url';
|
||||
|
||||
import { disconnect } from '@/app/lib/authAction';
|
||||
import { fetchEstablishment } from '@/app/lib/schoolAction';
|
||||
import { disconnect } from '@/app/actions/authAction';
|
||||
import { fetchEstablishment } from '@/app/actions/schoolAction';
|
||||
import ProtectedRoute from '@/components/ProtectedRoute';
|
||||
import { SessionProvider } from 'next-auth/react';
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import { useTranslations } from 'next-intl';
|
||||
import { Users, Clock, CalendarCheck, School, TrendingUp, UserCheck } from 'lucide-react';
|
||||
import Loader from '@/components/Loader';
|
||||
import ClasseDetails from '@/components/ClasseDetails';
|
||||
import { fetchClasses } from '@/app/lib/schoolAction';
|
||||
import { fetchClasses } from '@/app/actions/schoolAction';
|
||||
|
||||
// Composant StatCard pour afficher une statistique
|
||||
const StatCard = ({ title, value, icon, change, color = "blue" }) => (
|
||||
|
||||
@ -9,22 +9,22 @@ import { ClassesProvider } from '@/context/ClassesContext';
|
||||
import { createDatas,
|
||||
updateDatas,
|
||||
removeDatas,
|
||||
fetchSpecialities,
|
||||
fetchTeachers,
|
||||
fetchClasses,
|
||||
fetchSchedules,
|
||||
fetchRegistrationDiscounts,
|
||||
fetchTuitionDiscounts,
|
||||
fetchRegistrationFees,
|
||||
fetchSpecialities,
|
||||
fetchTeachers,
|
||||
fetchClasses,
|
||||
fetchSchedules,
|
||||
fetchRegistrationDiscounts,
|
||||
fetchTuitionDiscounts,
|
||||
fetchRegistrationFees,
|
||||
fetchTuitionFees,
|
||||
fetchRegistrationPaymentPlans,
|
||||
fetchTuitionPaymentPlans,
|
||||
fetchRegistrationPaymentModes,
|
||||
fetchTuitionPaymentModes } from '@/app/lib/schoolAction';
|
||||
fetchTuitionPaymentModes } from '@/app/actions/schoolAction';
|
||||
import SidebarTabs from '@/components/SidebarTabs';
|
||||
import FilesManagement from '@/components/Structure/Files/FilesManagement';
|
||||
|
||||
import { fetchRegisterFormFileTemplate } from '@/app/lib/subscriptionAction';
|
||||
import { fetchRegisterFormFileTemplate } from '@/app/actions/subscriptionAction';
|
||||
|
||||
|
||||
|
||||
@ -156,7 +156,7 @@ export default function Page() {
|
||||
|
||||
const handleRegistrationPaymentPlans = () => {
|
||||
fetchRegistrationPaymentPlans()
|
||||
.then(data => {
|
||||
.then(data => {
|
||||
setRegistrationPaymentPlans(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching registration payment plans:', error));
|
||||
@ -164,7 +164,7 @@ export default function Page() {
|
||||
|
||||
const handleTuitionPaymentPlans = () => {
|
||||
fetchTuitionPaymentPlans()
|
||||
.then(data => {
|
||||
.then(data => {
|
||||
setTuitionPaymentPlans(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching tuition payment plans:', error));
|
||||
@ -172,7 +172,7 @@ export default function Page() {
|
||||
|
||||
const handleRegistrationPaymentModes = () => {
|
||||
fetchRegistrationPaymentModes()
|
||||
.then(data => {
|
||||
.then(data => {
|
||||
setRegistrationPaymentModes(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching registration payment modes:', error));
|
||||
@ -180,7 +180,7 @@ export default function Page() {
|
||||
|
||||
const handleTuitionPaymentModes = () => {
|
||||
fetchTuitionPaymentModes()
|
||||
.then(data => {
|
||||
.then(data => {
|
||||
setTuitionPaymentModes(data);
|
||||
})
|
||||
.catch(error => console.error('Error fetching tuition payment modes:', error));
|
||||
|
||||
@ -5,7 +5,7 @@ import InscriptionFormShared from '@/components/Inscription/InscriptionFormShare
|
||||
import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { mockStudent } from '@/data/mockStudent';
|
||||
import { editRegisterForm, fetchRegisterForm } from '@/app/lib/subscriptionAction';
|
||||
import { editRegisterForm, fetchRegisterForm } from '@/app/actions/subscriptionAction';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
|
||||
@ -26,16 +26,16 @@ import {
|
||||
archiveRegisterForm,
|
||||
fetchRegisterFormFileTemplate,
|
||||
fetchStudents,
|
||||
editRegisterForm } from "@/app/lib/subscriptionAction"
|
||||
editRegisterForm } from "@/app/actions/subscriptionAction"
|
||||
|
||||
import {
|
||||
fetchClasses,
|
||||
fetchRegistrationDiscounts,
|
||||
fetchTuitionDiscounts,
|
||||
fetchRegistrationFees,
|
||||
fetchTuitionFees } from '@/app/lib/schoolAction';
|
||||
fetchTuitionFees } from '@/app/actions/schoolAction';
|
||||
|
||||
import { createProfile } from '@/app/lib/authAction';
|
||||
import { createProfile } from '@/app/actions/authAction';
|
||||
|
||||
import {
|
||||
BASE_URL,
|
||||
@ -43,7 +43,7 @@ import {
|
||||
|
||||
import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { fetchRegistrationFileGroups } from '@/app/lib/registerFileGroupAction';
|
||||
import { fetchRegistrationFileGroups } from '@/app/actions/registerFileGroupAction';
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -4,7 +4,7 @@ import InscriptionFormShared from '@/components/Inscription/InscriptionFormShare
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { FE_PARENTS_HOME_URL} from '@/utils/Url';
|
||||
import { editRegisterForm} from '@/app/lib/subscriptionAction';
|
||||
import { editRegisterForm} from '@/app/actions/subscriptionAction';
|
||||
|
||||
export default function Page() {
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
@ -7,10 +7,10 @@ import { User, MessageSquare, LogOut, Settings, Home } from 'lucide-react'; // A
|
||||
import Logo from '@/components/Logo'; // Ajout de l'importation du composant Logo
|
||||
import { FE_PARENTS_HOME_URL,FE_PARENTS_MESSAGERIE_URL,FE_PARENTS_SETTINGS_URL } from '@/utils/Url'; // Ajout de l'importation de l'URL de la page d'accueil parent
|
||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||
import { fetchMessages } from '@/app/lib/messagerieAction';
|
||||
import { fetchMessages } from '@/app/actions/messagerieAction';
|
||||
import ProtectedRoute from '@/components/ProtectedRoute';
|
||||
import { SessionProvider } from 'next-auth/react';
|
||||
import { disconnect } from '@/app/lib/authAction';
|
||||
import { disconnect } from '@/app/actions/authAction';
|
||||
import Popup from '@/components/Popup';
|
||||
|
||||
export default function Layout({
|
||||
|
||||
@ -6,7 +6,7 @@ import { Edit } from 'lucide-react';
|
||||
import StatusLabel from '@/components/StatusLabel';
|
||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
||||
import { fetchChildren } from '@/app/lib/subscriptionAction';
|
||||
import { fetchChildren } from '@/app/actions/subscriptionAction';
|
||||
|
||||
export default function ParentHomePage() {
|
||||
const [actions, setActions] = useState([]);
|
||||
|
||||
7
Front-End/src/app/[locale]/users/login/error.js
Normal file
7
Front-End/src/app/[locale]/users/login/error.js
Normal file
@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
|
||||
function ErrorBoundary({
|
||||
error
|
||||
}) {
|
||||
return <>{error.message}</>;
|
||||
}
|
||||
@ -13,6 +13,7 @@ import {
|
||||
FE_ADMIN_SUBSCRIPTIONS_URL,
|
||||
FE_PARENTS_HOME_URL
|
||||
} from '@/utils/Url';
|
||||
import { login } from '@/app/actions/authAction';
|
||||
import useLocalStorage from '@/hooks/useLocalStorage';
|
||||
import { signIn, getSession } from 'next-auth/react';
|
||||
import { useCsrfToken } from '@/context/CsrfContext'; // Importez le hook useCsrfToken
|
||||
@ -36,59 +37,15 @@ export default function Page() {
|
||||
return data.errorMessage === ""
|
||||
}
|
||||
|
||||
/*async function handleFormLogin(formData) {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const result = await signIn('credentials', {
|
||||
redirect: false,
|
||||
email: formData.get('login'),
|
||||
password: formData.get('password'),
|
||||
});
|
||||
|
||||
console.log('Sign In Result', result);
|
||||
setIsLoading(false);
|
||||
|
||||
if (result.error) {
|
||||
setErrorMessage(result.error);
|
||||
} else {
|
||||
const session = await getSession();
|
||||
if (!session || !session.user) {
|
||||
throw new Error('Session not found');
|
||||
}
|
||||
const user = session.user;
|
||||
console.log('User Session:', user);
|
||||
localStorage.setItem('userId', user.id); // Stocker l'identifiant de l'utilisateur
|
||||
if (user.droit === 0) {
|
||||
// Vue ECOLE
|
||||
} else if (user.droit === 1) {
|
||||
// Vue ADMIN
|
||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||
} else if (user.droit === 2) {
|
||||
// Vue PARENT
|
||||
router.push(FE_PARENTS_HOME_URL);
|
||||
} else {
|
||||
// Cas anormal
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during sign in:', error);
|
||||
setIsLoading(false);
|
||||
setErrorMessage('An error occurred during sign in.');
|
||||
}
|
||||
}*/
|
||||
|
||||
function handleFormLogin(formData) {
|
||||
setIsLoading(true);
|
||||
|
||||
signIn('credentials', {
|
||||
redirect: false,
|
||||
|
||||
login({
|
||||
email: formData.get('login'),
|
||||
password: formData.get('password'),
|
||||
}).then(result => {
|
||||
console.log('Sign In Result', result);
|
||||
setIsLoading(false);
|
||||
|
||||
if (result.error) {
|
||||
setErrorMessage(result.error);
|
||||
} else {
|
||||
|
||||
@ -11,7 +11,7 @@ import Popup from '@/components/Popup'; // Importez le composant Popup
|
||||
import { User } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { sendNewPassword } from '@/app/lib/authAction';
|
||||
import { sendNewPassword } from '@/app/actions/authAction';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import Popup from '@/components/Popup';
|
||||
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||
import { KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { getResetPassword, resetPassword } from '@/app/lib/authAction';
|
||||
import { getResetPassword, resetPassword } from '@/app/actions/authAction';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import Popup from '@/components/Popup'; // Importez le composant Popup
|
||||
import { User, KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { subscribe } from '@/app/lib/authAction';
|
||||
import { subscribe } from '@/app/actions/authAction';
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
export default function Page() {
|
||||
|
||||
Reference in New Issue
Block a user