From d35941d643b0744effb400a668f45df1ef24816e Mon Sep 17 00:00:00 2001
From: Anjaliavv51 <154777864+Anjaliavv51@users.noreply.github.com>
Date: Tue, 4 Jun 2024 14:20:07 +0530
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E[bug]:Signup=20with=20google=20isn'?=
=?UTF-8?q?t=20working?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
issue #427
---
login.html | 8 ++++---
signedup.html | 34 +++++++++++++++++++++++++++
signupjs.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+), 3 deletions(-)
create mode 100644 signedup.html
create mode 100644 signupjs.js
diff --git a/login.html b/login.html
index 16c9cd67..a6db2f5a 100644
--- a/login.html
+++ b/login.html
@@ -8,6 +8,8 @@
+
+
@@ -27,7 +29,7 @@
RAPIDOC
or use your account
@@ -51,8 +53,8 @@
RAPIDOC
or use your account
diff --git a/signedup.html b/signedup.html
new file mode 100644
index 00000000..75e1cafe
--- /dev/null
+++ b/signedup.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ RAPIDOC
+
+
+
+
+
+
+
+
+
+
+
diff --git a/signupjs.js b/signupjs.js
new file mode 100644
index 00000000..18408a4c
--- /dev/null
+++ b/signupjs.js
@@ -0,0 +1,63 @@
+import { initializeApp } from "https://www.gstatic.com/firebasejs/10.11.1/firebase-app.js";
+import { getAuth, GoogleAuthProvider, signInWithPopup } from "https://www.gstatic.com/firebasejs/10.11.1/firebase-auth.js";
+
+const firebaseConfig = {
+ apiKey: "AIzaSyDx_FcoL3XJryt6BInhOaDsMKiSmxzrYBI",
+ authDomain: "fir-7f3dd.firebaseapp.com",
+ projectId: "fir-7f3dd",
+ storageBucket: "fir-7f3dd.appspot.com",
+ messagingSenderId: "467011865433",
+ appId: "1:467011865433:web:e23be9d0cc3496bb961a48"
+};
+
+const app = initializeApp(firebaseConfig);
+const auth = getAuth(app);
+auth.languageCode = 'en';
+
+const provider = new GoogleAuthProvider();
+
+document.getElementById("google").addEventListener("click", function() {
+ signInWithPopup(auth, provider)
+ .then((result) => {
+ const credential = GoogleAuthProvider.credentialFromResult(result);
+ const user = result.user;
+ console.log(user);
+ window.location.href = "/signedup.html";
+ }).catch((error) => {
+ console.error("Error during Google sign-in:", error);
+ });
+});
+
+document.getElementById("signup-form").addEventListener("submit", function(event) {
+ event.preventDefault(); // Prevent form from submitting the default way
+ const name = document.getElementById("name").value;
+ const email = document.getElementById("email").value;
+ const password = document.getElementById("password").value;
+
+ if (validateForm(name, email, password)) {
+ // Simulate a successful registration (Replace with actual Firebase sign-up logic)
+ console.log("Form submitted with:", { name, email, password });
+ window.location.href = "/signed.html";
+ }
+});
+
+function validateForm(name, email, password) {
+ if (name === "" || email === "" || password === "") {
+ alert("All fields are required!");
+ return false;
+ }
+ if (!validateEmail(email)) {
+ alert("Please enter a valid email address.");
+ return false;
+ }
+ if (password.length < 6) {
+ alert("Password must be at least 6 characters long.");
+ return false;
+ }
+ return true;
+}
+
+function validateEmail(email) {
+ const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ return re.test(email);
+}