-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs Auth .js
More file actions
23 lines (18 loc) · 775 Bytes
/
Copy pathjs Auth .js
File metadata and controls
23 lines (18 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { app } from "./firebase.js";
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword }
from "https://www.gstatic.com/firebasejs/9.23.0/firebase-auth.js";
const auth = getAuth(app);
window.login = function(){
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
signInWithEmailAndPassword(auth,email,password)
.then(()=> window.location="dashboard.html")
.catch(e=>alert(e.message));
}
window.signup = function(){
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
createUserWithEmailAndPassword(auth,email,password)
.then(()=> alert("Account created successfully!"))
.catch(e=>alert(e.message));
}