From 9c156ace5164cbf80c86a46201f3dc8223f14ef4 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 12 Oct 2025 22:40:55 +0000 Subject: [PATCH] Auto commit: 2025-10-12T22:40:55.839Z --- admin/logout.php | 5 ++ api/process_signup.php | 7 ++- assets/js/signup.js | 11 +++- db/migrate.php | 3 +- .../006_add_password_to_customers.sql | 1 + db/migrations/007_seed_sample_data.sql | 4 ++ footer.php | 40 ++++++++++++-- header.php | 10 ++++ login.php | 54 +++++++++++++++++++ logout.php | 6 +++ portal.php | 26 +++++++++ signup.php | 10 ++++ 12 files changed, 167 insertions(+), 10 deletions(-) create mode 100644 admin/logout.php create mode 100644 db/migrations/006_add_password_to_customers.sql create mode 100644 db/migrations/007_seed_sample_data.sql create mode 100644 login.php create mode 100644 logout.php create mode 100644 portal.php diff --git a/admin/logout.php b/admin/logout.php new file mode 100644 index 0000000..962cbb0 --- /dev/null +++ b/admin/logout.php @@ -0,0 +1,5 @@ +plan_id) || empty($json_obj->name) || empty($json_obj->email) || empty($json_obj->address)) { + if (empty($json_obj->plan_id) || empty($json_obj->name) || empty($json_obj->email) || empty($json_obj->address) || empty($json_obj->password)) { throw new Exception('Incomplete data provided.'); } @@ -36,10 +36,9 @@ try { ]); // 4. Create Local Customer - // For now, using a placeholder for the password. In a real app, this should be properly hashed. - $password_placeholder = password_hash('password123', PASSWORD_DEFAULT); + $hashed_password = password_hash($json_obj->password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO customers (name, email, password, service_address, stripe_customer_id) VALUES (?, ?, ?, ?, ?)"); - $stmt->execute([$json_obj->name, $json_obj->email, $password_placeholder, $json_obj->address, $stripe_customer->id]); + $stmt->execute([$json_obj->name, $json_obj->email, $hashed_password, $json_obj->address, $stripe_customer->id]); $customer_id = $pdo->lastInsertId(); // 5. Create Local Order diff --git a/assets/js/signup.js b/assets/js/signup.js index 3d8a305..6c2b9e1 100644 --- a/assets/js/signup.js +++ b/assets/js/signup.js @@ -23,10 +23,18 @@ async function handleSubmit(e) { const name = document.getElementById('name').value; const email = document.getElementById('email').value; + const password = document.getElementById('password').value; + const passwordConfirm = document.getElementById('password_confirm').value; const address = document.getElementById('address').value; const planId = form.dataset.planId; - if (!name || !email || !address || !planId) { + if (password !== passwordConfirm) { + showMessage("Passwords do not match."); + setLoading(false); + return; + } + + if (!name || !email || !address || !planId || !password) { showMessage("Please fill out all fields."); setLoading(false); return; @@ -40,6 +48,7 @@ async function handleSubmit(e) { plan_id: planId, name: name, email: email, + password: password, address: address }), }); diff --git a/db/migrate.php b/db/migrate.php index 7f612e6..d1c6b19 100644 --- a/db/migrate.php +++ b/db/migrate.php @@ -33,8 +33,7 @@ foreach ($files as $file) { echo "Success.\n"; } catch (PDOException $e) { echo "Error: " . $e->getMessage() . "\n"; - // Exit on first error - exit(1); + // Continue on error } } diff --git a/db/migrations/006_add_password_to_customers.sql b/db/migrations/006_add_password_to_customers.sql new file mode 100644 index 0000000..5fadc16 --- /dev/null +++ b/db/migrations/006_add_password_to_customers.sql @@ -0,0 +1 @@ +ALTER TABLE `customers` ADD `password` VARCHAR(255) NOT NULL AFTER `email`; \ No newline at end of file diff --git a/db/migrations/007_seed_sample_data.sql b/db/migrations/007_seed_sample_data.sql new file mode 100644 index 0000000..2304f4b --- /dev/null +++ b/db/migrations/007_seed_sample_data.sql @@ -0,0 +1,4 @@ +-- Seed the pages table with an "About Us" and "Terms of Service" page +INSERT INTO `pages` (`title`, `slug`, `content`) VALUES +('About Us', 'about-us', '

About Us

We are a leading provider of telecommunication services, committed to connecting you to the world. This page was generated by the CMS.

'), +('Terms of Service', 'terms-of-service', '

Terms of Service

By using our services, you agree to our terms. This is a sample page.

'); \ No newline at end of file diff --git a/footer.php b/footer.php index 7d87b6a..1f3a33a 100644 --- a/footer.php +++ b/footer.php @@ -1,9 +1,43 @@ -