| <!DOCTYPE html> |
| <html lang="en" data-theme="dark"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Register - Heart Health Analysis System</title> |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> |
| <style> |
| :root[data-theme="dark"] { |
| --primary-color: #f03e5f; |
| --secondary-color: #f5768d; |
| --accent-color: #d1062a; |
| --text-color: #ffffff; |
| --text-light: #fccad3; |
| --background-start: #1a1a2e; |
| --background-end: #16213e; |
| --card-color: rgba(26, 26, 46, 0.8); |
| --border-radius: 12px; |
| --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2); |
| --transition: all 0.3s ease; |
| } |
| |
| body { |
| background: linear-gradient(135deg, |
| rgba(26, 26, 46, 0.95) 0%, |
| rgba(22, 33, 62, 0.95) 50%, |
| rgba(209, 6, 42, 0.2) 100% |
| ); |
| color: var(--text-color); |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| min-height: 100vh; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| padding: 20px; |
| } |
| |
| .register-container { |
| background: var(--card-color); |
| border-radius: var(--border-radius); |
| padding: 40px; |
| box-shadow: var(--box-shadow); |
| width: 100%; |
| max-width: 400px; |
| border: 1px solid rgba(255, 255, 255, 0.1); |
| } |
| |
| .register-header { |
| text-align: center; |
| margin-bottom: 30px; |
| } |
| |
| .register-header h1 { |
| color: var(--primary-color); |
| font-size: 2rem; |
| margin-bottom: 10px; |
| } |
| |
| .register-header p { |
| color: var(--text-light); |
| opacity: 0.8; |
| } |
| |
| .form-control { |
| background: rgba(255, 255, 255, 0.1); |
| border: 2px solid rgba(255, 255, 255, 0.1); |
| color: var(--text-color); |
| padding: 12px; |
| border-radius: var(--border-radius); |
| margin-bottom: 20px; |
| } |
| |
| .form-control:focus { |
| background: rgba(255, 255, 255, 0.15); |
| border-color: var(--primary-color); |
| color: var(--text-color); |
| box-shadow: 0 0 0 2px rgba(240, 62, 95, 0.2); |
| } |
| |
| .btn-register { |
| background: linear-gradient(135deg, var(--primary-color), var(--accent-color)); |
| border: none; |
| color: white; |
| padding: 12px; |
| border-radius: var(--border-radius); |
| width: 100%; |
| font-weight: 500; |
| margin-top: 10px; |
| transition: var(--transition); |
| } |
| |
| .btn-register:hover { |
| transform: translateY(-2px); |
| box-shadow: 0 4px 12px rgba(240, 62, 95, 0.3); |
| } |
| |
| .login-link { |
| text-align: center; |
| margin-top: 20px; |
| color: var(--text-light); |
| } |
| |
| .login-link a { |
| color: var(--primary-color); |
| text-decoration: none; |
| font-weight: 500; |
| } |
| |
| .login-link a:hover { |
| text-decoration: underline; |
| } |
| |
| .alert { |
| background: rgba(240, 62, 95, 0.1); |
| border: 1px solid rgba(240, 62, 95, 0.2); |
| color: var(--text-color); |
| border-radius: var(--border-radius); |
| padding: 12px; |
| margin-bottom: 20px; |
| display: none; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="register-container"> |
| <div class="register-header"> |
| <h1><i class="fas fa-user-plus"></i> Register</h1> |
| <p>Create your account for Heart Health Analysis System</p> |
| </div> |
| |
| <div class="alert alert-danger" id="errorAlert" role="alert"></div> |
| |
| <form id="registerForm"> |
| <div class="mb-3"> |
| <input type="text" class="form-control" id="name" placeholder="Full Name" required> |
| </div> |
| <div class="mb-3"> |
| <input type="email" class="form-control" id="email" placeholder="Email address" required> |
| </div> |
| <div class="mb-3"> |
| <input type="password" class="form-control" id="password" placeholder="Password" required> |
| </div> |
| <div class="mb-3"> |
| <input type="password" class="form-control" id="confirmPassword" placeholder="Confirm Password" required> |
| </div> |
| <button type="submit" class="btn btn-register"> |
| <i class="fas fa-user-plus"></i> Register |
| </button> |
| </form> |
| |
| <div class="login-link"> |
| Already have an account? <a href="/login">Login here</a> |
| </div> |
| </div> |
|
|
| <script src="https://www.gstatic.com/firebasejs/9.6.0/firebase-app-compat.js"></script> |
| <script src="https://www.gstatic.com/firebasejs/9.6.0/firebase-auth-compat.js"></script> |
| <script> |
| |
| const firebaseConfig = {{ firebase_config|tojson|safe }}; |
| |
| |
| firebase.initializeApp(firebaseConfig); |
| |
| document.getElementById('registerForm').addEventListener('submit', async (e) => { |
| e.preventDefault(); |
| const name = document.getElementById('name').value; |
| const email = document.getElementById('email').value; |
| const password = document.getElementById('password').value; |
| const confirmPassword = document.getElementById('confirmPassword').value; |
| const errorAlert = document.getElementById('errorAlert'); |
| |
| if (password !== confirmPassword) { |
| errorAlert.style.display = 'block'; |
| errorAlert.textContent = 'Passwords do not match'; |
| return; |
| } |
| |
| try { |
| const userCredential = await firebase.auth().createUserWithEmailAndPassword(email, password); |
| await userCredential.user.updateProfile({ |
| displayName: name |
| }); |
| |
| const idToken = await userCredential.user.getIdToken(); |
| |
| |
| const response = await fetch('/verify-token', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify({ idToken }), |
| }); |
| |
| if (!response.ok) { |
| throw new Error('Token verification failed'); |
| } |
| |
| |
| window.location.href = '/'; |
| } catch (error) { |
| errorAlert.style.display = 'block'; |
| errorAlert.textContent = error.message; |
| } |
| }); |
| |
| |
| firebase.auth().onAuthStateChanged((user) => { |
| if (user) { |
| window.location.href = '/'; |
| } |
| }); |
| </script> |
| </body> |
| </html> |