mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Refactorisation du login et de admin/subscription
This commit is contained in:
@ -9,9 +9,10 @@ import InputTextIcon from '@/components/InputTextIcon';
|
||||
import Loader from '@/components/Loader'; // Importez le composant Loader
|
||||
import Button from '@/components/Button'; // Importez le composant Button
|
||||
import Popup from '@/components/Popup';
|
||||
import { BE_AUTH_RESET_PASSWORD_URL, FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||
import { KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||
import { FE_USERS_LOGIN_URL } from '@/utils/Url';
|
||||
import { KeySquare } from 'lucide-react'; // Importez directement les icônes nécessaires
|
||||
import useCsrfToken from '@/hooks/useCsrfToken';
|
||||
import { getResetPassword, resetPassword } from '@/app/lib/authAction';
|
||||
|
||||
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
|
||||
|
||||
@ -34,12 +35,7 @@ export default function Page() {
|
||||
setIsLoading(false);
|
||||
}, 1000);
|
||||
} else {
|
||||
const url= `${BE_AUTH_RESET_PASSWORD_URL}/${uuid}`;
|
||||
fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then(response => response.json())
|
||||
getResetPassword(uuid)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
setIsLoading(true);
|
||||
@ -65,22 +61,11 @@ export default function Page() {
|
||||
setPopupVisible(true);
|
||||
}, 1000);
|
||||
} else {
|
||||
const request = new Request(
|
||||
`${BE_AUTH_RESET_PASSWORD_URL}/${uuid}`,
|
||||
{
|
||||
method:'POST',
|
||||
headers: {
|
||||
'Content-Type':'application/json',
|
||||
'X-CSRFToken': csrfToken
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify( {
|
||||
password1: formData.get('password1'),
|
||||
password2: formData.get('password2'),
|
||||
}),
|
||||
}
|
||||
);
|
||||
fetch(request).then(response => response.json())
|
||||
const data = {
|
||||
password1: formData.get('password1'),
|
||||
password2: formData.get('password2'),
|
||||
}
|
||||
resetPassword(uuid,data,csrfToken)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
setPassword1FieldError("")
|
||||
|
||||
Reference in New Issue
Block a user