-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
48 lines (41 loc) · 1.82 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.6.0/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.6.0/firebase-auth.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAtuWsrjByIaTCxEh3WC3aasdTEeidR3n4",
authDomain: "signup-form-81b01.firebaseapp.com",
projectId: "signup-form-81b01",
storageBucket: "signup-form-81b01.appspot.com",
messagingSenderId: "241029541836",
appId: "1:241029541836:web:3b4279281b4bad0d58b769"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth();
var firstname = document.getElementById("firstname");
var lastname = document.getElementById("lastname");
var email = document.getElementById("Email");
var passwords = document.getElementById("password");
window.signup = function (e) {
e.preventDefault();
var obj = {
firstname: firstname.value,
lastname: lastname.value,
email: email.value,
passwords: passwords.value,
};
createUserWithEmailAndPassword(auth, obj.email, obj.passwords)
.then(function (userCredential) {
// After successful signup, you can access the user information from userCredential.user
var user = userCredential.user;
console.log("Signup Successful. User UID:", user.uid);
// Redirect to the home page or any other desired page
window.location.href = "index.html"; // Replace "index.html" with your actual home page URL
})
.catch(function (error) {
// Handle signup errors
console.error("Signup failed:", error.message);
alert("Signup failed. Please check your information and try again.");
});
};