le site doit etre veroiller et accessible apres creation compte avec nom, prenom et choisir un mot de passe. une fois ouvert on a un catalogue de produits. photo de produit.
ff6910b verified Download script.js from abdoulayedabel16/snapauth-gallery-vault: direct link, hf CLI and curl.
- Browser
- Download file 2.89 kB
-
https://huggingface.co/spaces/abdoulayedabel16/snapauth-gallery-vault/resolve/main/script.js
- Command line
-
hf download hf://spaces/abdoulayedabel16/snapauth-gallery-vault/script.js
-
curl -L -o script.js https://huggingface.co/spaces/abdoulayedabel16/snapauth-gallery-vault/resolve/main/script.js
2.89 kB
| // Handle login form submission | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const loginForm = document.getElementById('login-form'); | |
| if (loginForm) { | |
| loginForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const email = document.getElementById('email').value; | |
| const password = document.getElementById('password').value; | |
| if (email && password) { | |
| const users = JSON.parse(localStorage.getItem('users') || '[]'); | |
| const user = users.find(u => u.email === email && u.password === password); | |
| if (user) { | |
| localStorage.setItem('authToken', 'dummy-token'); | |
| localStorage.setItem('currentUser', JSON.stringify(user)); | |
| window.location.href = 'gallery.html'; | |
| } else { | |
| alert('Email ou mot de passe incorrect'); | |
| } | |
| } else { | |
| alert('Veuillez remplir tous les champs'); | |
| } | |
| }); | |
| } | |
| // Handle registration form | |
| const registerForm = document.getElementById('register-form'); | |
| if (registerForm) { | |
| registerForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const firstname = document.getElementById('firstname').value; | |
| const lastname = document.getElementById('lastname').value; | |
| const email = document.getElementById('email').value; | |
| const password = document.getElementById('password').value; | |
| if (firstname && lastname && email && password) { | |
| const users = JSON.parse(localStorage.getItem('users') || '[]'); | |
| // Check if email already exists | |
| if (users.some(u => u.email === email)) { | |
| alert('Cet email est déjà utilisé'); | |
| return; | |
| } | |
| const newUser = { | |
| id: Date.now(), | |
| firstname, | |
| lastname, | |
| email, | |
| password | |
| }; | |
| users.push(newUser); | |
| localStorage.setItem('users', JSON.stringify(users)); | |
| localStorage.setItem('authToken', 'dummy-token'); | |
| localStorage.setItem('currentUser', JSON.stringify(newUser)); | |
| window.location.href = 'gallery.html'; | |
| } else { | |
| alert('Veuillez remplir tous les champs'); | |
| } | |
| }); | |
| } | |
| // Check authentication on gallery page | |
| if (window.location.pathname.includes('gallery.html')) { | |
| if (!localStorage.getItem('authToken')) { | |
| window.location.href = 'index.html'; | |
| } | |
| } | |
| }); | |