Spaces:
Running
Running
Download script.js from Flaaaaw/securesign-galaxy: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/spaces/Flaaaaw/securesign-galaxy/resolve/main/script.js
- Command line
-
hf download hf://spaces/Flaaaaw/securesign-galaxy/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Flaaaaw/securesign-galaxy/resolve/main/script.js
2.13 kB
| // Store users in localStorage for demo purposes | |
| const users = JSON.parse(localStorage.getItem('users')) || []; | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Login Form Handler | |
| const loginForm = document.getElementById('loginForm'); | |
| if (loginForm) { | |
| loginForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const email = document.getElementById('loginEmail').value; | |
| const password = document.getElementById('loginPassword').value; | |
| const user = users.find(u => u.email === email && u.password === password); | |
| if (user) { | |
| alert('Login successful!'); | |
| // In a real app, you would redirect to dashboard | |
| } else { | |
| alert('Invalid credentials!'); | |
| } | |
| }); | |
| } | |
| // Register Form Handler | |
| const registerForm = document.getElementById('registerForm'); | |
| if (registerForm) { | |
| registerForm.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const name = document.getElementById('registerName').value; | |
| const email = document.getElementById('registerEmail').value; | |
| const password = document.getElementById('registerPassword').value; | |
| const confirmPassword = document.getElementById('registerConfirmPassword').value; | |
| // Validate passwords match | |
| if (password !== confirmPassword) { | |
| alert('Passwords do not match!'); | |
| return; | |
| } | |
| // Check if user already exists | |
| const userExists = users.some(u => u.email === email); | |
| if (userExists) { | |
| alert('Email already registered!'); | |
| return; | |
| } | |
| // Add new user | |
| users.push({ name, email, password }); | |
| localStorage.setItem('users', JSON.stringify(users)); | |
| alert('Registration successful! You can now login.'); | |
| window.location.href = 'index.html'; | |
| }); | |
| } | |
| }); | |