Skip to content

Commit

Permalink
Merge pull request Anishkagupta04#994 from Bhattu-Anitha-07/email_val…
Browse files Browse the repository at this point in the history
…idation

Fixes issue Anishkagupta04#949
  • Loading branch information
varshith257 authored Jul 25, 2024
2 parents e990ba0 + 21acb5d commit 85cf731
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 38 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1503,4 +1503,4 @@ <h4>RAPIDOC Newsletter</h4><br>
});

</script>
</body>
</body>
26 changes: 6 additions & 20 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
var swiper = new Swiper(".swiper", {
loop: true,
centerSlide: true,
fade: true,
grabCursor: 'true',
pagination: {
el: ".swiper-pagination",
clickable: true,
dynamicBullets: true,
},
navigation:{
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
breakpoints:{
0:{
slidesPerView: 1,
}
},
});
document.getElementById('login').addEventListener('click', () => {
document.getElementById('container').classList.remove('right-panel-active');
});

document.getElementById('register').addEventListener('click', () => {
document.getElementById('container').classList.add('right-panel-active');
});
110 changes: 96 additions & 14 deletions log/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
<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 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="login.css">
<script src="scriptsignup.js" defer type="module"></script>
<script src="signupjs.js" defer type="module"></script>
<script src="signupjs1.js" defer type="module"></script>
<script src="https://www.gstatic.com/firebasejs/9.9.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.9.2/firebase-auth-compat.js"></script>
<meta name="google-signin-client_id" content="646664380070-n07i34glgcc6sanb59p3m1k5k0cgn1v1.apps.googleusercontent.com">
</head>
<body>
Expand All @@ -25,8 +24,8 @@
<div class="form-container register-container">
<form action="#" id="registerForm">
<h1>RAPIDOC</h1>
<input type="text" placeholder="Name">
<input type="email" placeholder="Email">
<input type="text" id="registerName" placeholder="Name">
<input type="email" id="registerEmail" placeholder="Email">
<div class="password-container">
<input type="password" id="registerPassword" placeholder="Password">
<span toggle="#registerPassword" class="eye toggle-password">
Expand All @@ -35,8 +34,6 @@ <h1>RAPIDOC</h1>
<path d="M17.5 12c-1.297 0-2.5-.768-3.5-1.854C12.5 9.768 11.297 9 10 9s-2.5.768-4 1.146c-1 1.086-2.203 1.854-3.5 1.854" />
<path d="M1 12s4-8 11-8s11 8 11 8s-4 8-11 8s-11-8-11-8z" />
</svg>


</span>
</div>
<button type="submit">Register</button>
Expand All @@ -52,7 +49,7 @@ <h1>RAPIDOC</h1>
<div class="form-container login-container">
<form action="#" id="loginForm">
<h1>RAPIDOC</h1>
<input type="email" placeholder="Email">
<input type="email" id="loginEmail" placeholder="Email">
<div class="password-container">
<input type="password" id="loginPassword" placeholder="Password">
<span toggle="#loginPassword" class="eye toggle-password">
Expand All @@ -61,8 +58,6 @@ <h1>RAPIDOC</h1>
<path d="M17.5 12c-1.297 0-2.5-.768-3.5-1.854C12.5 9.768 11.297 9 10 9s-2.5.768-4 1.146c-1 1.086-2.203 1.854-3.5 1.854" />
<path d="M1 12s4-8 11-8s11 8 11 8s-4 8-11 8s-11-8-11-8z" />
</svg>


</span>
</div>
<div class="content">
Expand Down Expand Up @@ -102,10 +97,97 @@ <h1 class="title">Start your <br> journey now</h1>
</div>
</div>
</div>

</div>

<script src="script.js"></script>
</div>
<script src="/js/script.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.9.2/firebase-app.js";
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, sendEmailVerification, reload, deleteUser } from "https://www.gstatic.com/firebasejs/9.9.2/firebase-auth.js";

// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT_ID.appspot.com",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
measurementId: "YOUR_MEASUREMENT_ID" // optional
};


// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

// Register event
const registerForm = document.getElementById('registerForm');
registerForm.addEventListener('submit', async (e) => {
e.preventDefault();

const email = document.getElementById('registerEmail').value;
const password = document.getElementById('registerPassword').value;

try {
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
const user = userCredential.user;

// Set a timeout for checking email verification
const timeout = setTimeout(async () => {
await reload(user);
if (!user.emailVerified) {
await deleteUser(user)
.then(() => {
alert('Account deleted due to unverified email.');
location.reload(); // Reload the page after deletion
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
alert(errorMessage);
location.reload(); // Reload the page on error
});
}
}, 30000); // 30 seconds

await sendEmailVerification(user);
alert('Registration successful! Please check your email to verify your account.');
} catch (error) {
const errorCode = error.code;
const errorMessage = error.message;
alert(errorMessage);
location.reload(); // Reload the page on error
}
});

// Login event
const loginForm = document.getElementById('loginForm');
loginForm.addEventListener('submit', async (e) => {
e.preventDefault();

const email = document.getElementById('loginEmail').value;
const password = document.getElementById('loginPassword').value;

try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
const user = userCredential.user;

// Check if email is verified
await reload(user); // Ensure latest user data is fetched
if (user.emailVerified) {
window.location.href = '/index.html'; // Redirect to index.html upon successful login
} else {
alert('Please verify your email address.');
}
} catch (error) {
const errorCode = error.code;
const errorMessage = error.message;
alert(errorMessage);
location.reload(); // Reload the page on error
}
});
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions log/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ document.addEventListener("DOMContentLoaded", function() {
const loginForm = document.getElementById("loginForm");

const successBanner = document.createElement("div");
successBanner.id = "successBanner";
successBanner.textContent = "Login Successful";
// successBanner.id = "successBanner";
// successBanner.textContent = "Login Successful";
document.body.appendChild(successBanner);

// Function to toggle password visibility
Expand Down Expand Up @@ -68,6 +68,6 @@ document.addEventListener("DOMContentLoaded", function() {
setTimeout(() => {
successBanner.style.display = "none";
window.location.href = "login.html"; // Change "login.html" to your desired URL
}, 2000); // Display banner for 2 seconds
}, 500); // Display banner for 2 seconds
});
});
36 changes: 36 additions & 0 deletions read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--> Setting up a Firebase account is a straightforward process. Follow these steps to create and configure your Firebase project:
--> Create a Google Account:
If you don't already have a Google account, create one at Google Sign Up.
--> Access Firebase:
Go to the Firebase Console.
--> Create a Firebase Project:
Click on the "Add project" button.
Enter a project name and click "Continue".
(Optional) You can enable Google Analytics for your project. If you do, select the Google Analytics account you want to use. Click "Continue".
Configure Google Analytics settings (if enabled) and click "Create project".
--> Add Firebase to Your App:
Once your project is created, you will be taken to the Firebase project overview page.
Click on the platform icon for the type of app you are building (Web, iOS, Android).
--> Register Your App:
For a web app, you will need to enter a nickname for your app and optionally set up Firebase Hosting. Click "Register app".
--> Add Firebase SDK:
After registering your app, you will be provided with a Firebase configuration snippet. Copy this configuration.
Add the Firebase SDK to your project by including the provided script tags in your HTML file:
-> html code:
<!-- Firebase App (the core Firebase SDK) -->
<script src="https://www.gstatic.com/firebasejs/9.1.2/firebase-app.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/9.1.2/firebase-auth.js"></script>
--> Initialize Firebase in Your Project:
In your JavaScript file (e.g., login.js), initialize Firebase using the configuration details:
--> javascript code:
<!--Your web app's Firebase configuration -->
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT_ID.appspot.com",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
measurementId: "YOUR_MEASUREMENT_ID"
};

0 comments on commit 85cf731

Please sign in to comment.