-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
41 lines (36 loc) · 1.49 KB
/
signup.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
// Import the Firebase SDK modules
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-auth.js";
// Your Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyCJKSXv32xRhwfdEZPBl4h5NGKBV6PSBTo",
authDomain: "vistel-aa166.firebaseapp.com",
projectId: "vistel-aa166",
storageBucket: "vistel-aa166.appspot.com",
messagingSenderId: "866833870372",
appId: "1:866833870372:web:968919efd2d0430672b2b1",
measurementId: "G-SR4078H6SP"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
// Handle the signup form submission
document.getElementById('signup-form').addEventListener('submit', (e) => {
e.preventDefault(); // Prevent the form from refreshing the page
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
// Create a new user with email and password
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
alert("User signed up successfully!");
console.log("User info:", user);
// Redirect or perform other actions here
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
alert("Error: " + errorMessage);
});
});