Skip to content

Commit

Permalink
🐞[bug]:Signup with google isn't working
Browse files Browse the repository at this point in the history
issue #427
  • Loading branch information
Anjaliavv51 committed Jun 4, 2024
1 parent db6c481 commit d35941d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
8 changes: 5 additions & 3 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link rel="icon" type="image/x-icon" href="log/favicon.ico">
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
<link rel="stylesheet" href="log/login.css">
<script src="scriptsignup.js" defer type="module"></script>
<script src="signupjs.js" defer type="module"></script>
</head>
<body>
<div class="container" id="container">
Expand All @@ -27,7 +29,7 @@ <h1>RAPIDOC </h1>
<span>or use your account</span>
<div class="social-container">
<a href="www.facebook.com" class="social"><i class="lni lni-facebook-fill"></i></a>
<a href="www.google.com" class="social"><i class="lni lni-google"></i></a>
<a id="google" class="social"><i class="lni lni-google"></i></a>
<a href="www.linkedin.com" class="social"><i class="lni lni-linkedin-original"></i></a>
</div>
</form>
Expand All @@ -51,8 +53,8 @@ <h1>RAPIDOC</h1>
<span>or use your account</span>
<div class="social-container">
<a href="www.facebook.com" class="social"><i class="lni lni-facebook-fill"></i></a>
<a href="www.google.com" class="social"><i class="lni lni-google"></i></a>
<a href="www.linkedin.com" class="social"><i class="lni lni-linkedin-original"></i></a>
<a class="social" id="google"><i class="lni lni-google"></i></a>
<a href="www.linkedin.com" class="social" id="google"><i class="lni lni-linkedin-original"></i></a>
</div>
</form>
</div>
Expand Down
34 changes: 34 additions & 0 deletions signedup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RAPIDOC</title>
<link rel="icon" type="image/x-icon" href="log/favicon.ico">
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
<link rel="stylesheet" href="log/login.css">
</head>
<body>
<div class="container" id="container">
<div class="form-container login-container">
<form action="#">
<h1>Signup Completed Successfully!</h1>
<button class="ghost" style="color: black;"><a href="index.html">Back to Home
<i class="lni lni-arrow-right register" style="rotate: 180deg;"></i></a>
</button>
</form>
</div>

<div class="overlay-container">
<div class="overlay">

</div>
</div>

</div>

<script src="log/script.js"></script>

</body>
</html>
63 changes: 63 additions & 0 deletions signupjs.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit d35941d

Please sign in to comment.