-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from meriemno/meriemno-patch-1
Meriemno patch 1
- Loading branch information
Showing
97 changed files
with
1,266 additions
and
80 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
const emailUser = document.querySelector('#email'); | ||
const passwordUser = document.querySelector('#password'); | ||
const formulaire = document.querySelector('form'); | ||
const message = document.querySelector('form .erreur'); | ||
const loged = window.localStorage.loged; | ||
|
||
|
||
|
||
|
||
async function validateForm() { | ||
formulaire.addEventListener('submit', async (event) => { | ||
|
||
|
||
event.preventDefault(); | ||
//declarer les variables et recuperer la saisi | ||
let email = emailUser.value; | ||
let password = passwordUser.value; | ||
//affichage console | ||
|
||
if (!email || !password) { | ||
// Gérer l'erreur de validation, par exemple, afficher un message à l'utilisateur | ||
console.log('Veuillez remplir tous les champs obligatoires.'); | ||
message.textContent = 'Veuillez remplir tous les champs obligatoires.'; | ||
return; | ||
} | ||
|
||
|
||
try { | ||
//fetch post | ||
|
||
const response = await fetch('http://localhost:5678/api/users/login', { | ||
|
||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
email: email, | ||
password: password | ||
}) | ||
}) | ||
if (!response.ok) { | ||
console.log(response.status, 'Unauthorized'); | ||
throw new Error('Non autorisé (Unauthorized). Veuillez vous connecter.', response.status); | ||
} | ||
|
||
const data = await response.json(); | ||
console.log(data); | ||
|
||
|
||
|
||
if (data.token) { | ||
console.log(data.token); | ||
//redirection vers la page d'accueil en mode creation | ||
window.sessionStorage.loged = true; | ||
window.sessionStorage.accessToken = data.token; | ||
console.log(data.token); | ||
window.location.href = 'index.html'; | ||
console.log(window.sessionStorage.loged); | ||
|
||
|
||
} else { | ||
|
||
message.textContent = 'Erreur dans l’identifiant ou le mot de passe'; | ||
message.style.color = 'red'; | ||
window.localStorage.removeItem('token'); | ||
window.sessionStorage.removeItem('token'); | ||
|
||
} | ||
} catch (error) { | ||
// console.log('Error:', error.name, 'Message:', error.message); | ||
if (error instanceof TypeError) { | ||
// La requête a échoué car le service n'est pas joignable | ||
console.log('Le service n\'est pas joignable. Veuillez réessayer plus tard.'); | ||
message.textContent = 'Le service n\'est pas joignable. Veuillez réessayer plus tard.' | ||
|
||
} else { | ||
// Une autre erreur s'est produite | ||
console.log('Une erreur inattendue s\'est produite:', error); | ||
message.textContent = 'Une erreur inattendue s\'est produite.' | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
|
||
}) | ||
|
||
} | ||
|
||
|
||
function init() { | ||
|
||
validateForm(); | ||
|
||
} | ||
|
||
init(); |
Oops, something went wrong.