-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (50 loc) · 1.94 KB
/
app.js
File metadata and controls
58 lines (50 loc) · 1.94 KB
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
import { auth, onAuthStateChanged, doc, db, getDoc } from "./firebase.js";
let loader = document.getElementById("loader");
let mainContent = document.getElementById("mainContent");
const name = document.getElementById("name");
const email = document.getElementById("email");
const number = document.getElementById("number");
const userImage = document.getElementById("userImage");
onAuthStateChanged(auth, async (user) => {
if (user) {
const docRef = await doc(db, "users", user.uid);
const docSnap = await getDoc(docRef);
if (!docSnap.exists()) {
await addDataToFirestore(user);
}
console.log("doc", docSnap.data())
if (docSnap.data()) {
if (location.pathname !== "/todo.html") {
window.location = "todo.html"
}
loader.style.display = "none"
mainContent.style.display = "block"
if (docSnap.data().photo) {
userImage.innerHTML = `<img alt="" src=${docSnap.data().photo} width="200"
height="200" class="avatar">`
} else {
userImage.innerHTML = `<img style="height:auto;" alt="" src="/Images/user.png" width="200"
height="200" class="avatar">`
}
if (docSnap.data().name) {
name.innerHTML = 'Name:' + " " + docSnap.data().name;
} else {
name.innerHTML = 'Name:' + " " + 'Not Found';
}
email.innerHTML = 'Email:' + " " + docSnap.data().email;
if (docSnap.data().number) {
number.innerHTML = 'Contact No:' + " " + docSnap.data().number;
} else {
number.innerHTML = 'Contact No:' + " " + 'Not Found';
}
console.log(user);
}
}
else {
if (location.pathname !== "/index.html") {
window.location = "index.html"
}
console.log("not login")
}
}
);