-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuslog.js
64 lines (55 loc) · 2.27 KB
/
cuslog.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.1.0/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/11.1.0/firebase-auth.js";
const firebaseConfig = {
apiKey: "AIzaSyB_oOpHkvWT8L8u6wE0pcYXAp364LLRxh4",
authDomain: "hyper-local-ab655.firebaseapp.com",
projectId: "hyper-local-ab655",
storageBucket: "hyper-local-ab655.firebasestorage.app",
messagingSenderId: "392195243875",
appId: "1:392195243875:web:e9887d2d68821ea7965d56"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const loginbtn = document.getElementById("login_btn");
const loginbtn2 = document.getElementById("login_btn2");
const signup = document.getElementById("signup");
const login = document.getElementById("login");
const signupbtn = document.getElementById("signup_btn");
const signupRedirect = document.getElementById("signup_redirect");
loginbtn.addEventListener('click', () => {
signup.style.display = 'none';
login.style.display = 'block';
});
signupRedirect.addEventListener('click', () => {
signup.style.display = 'block';
login.style.display = 'none';
});
signupbtn.addEventListener('click', (e) => {
e.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('Password').value;
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
alert("Signup Successful!");
console.log("User Created: ", userCredential.user);
signup.style.display = 'none';
login.style.display = 'block';
})
.catch((error) => {
alert(error.message);
});
});
loginbtn2.addEventListener('click', (e) => {
e.preventDefault();
const email = document.getElementById('email_login').value;
const password = document.getElementById('Password_login').value;
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
alert("Login Successful!");
console.log("Logged in User: ", userCredential.user);
window.location.href = "customer.html";
})
.catch((error) => {
alert(error.message);
});
});