-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauth.js
56 lines (50 loc) · 2.33 KB
/
auth.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
window.onload = function(){
const loginD = document.getElementById('login-icons');
const user = firebase.auth().currentUser;
if(user){
store.collection('c').doc(user.uid).get().then(doc => {
const html =
`
<utd-topbar-menu-button-renderer class="style-scope utd-masthead" use-keyboard-focused="">
<button id="avatar-btn" aria-haspopup="true" class="style-scope utd-topbar-menu-button-renderer" aria-label="Account profile photo">
<ut-img-shadow height="32" width="32" class="style-scope utd-topbar-menu-button-renderer no-transition" style="background-color: transparent;" loaded="">
<img id="img" href="/login.html" class="style-scope ut-img-shadow" alt="Avatar image" src="https://tallerthanshort.github.io/ut3.ggpht/icons/${doc.data().img}" width="32" height="32">
</ut-img-shadow>
</button>
<dom-if class="style-scope utd-topbar-menu-button-renderer">
<template is="dom-if"></template>
</dom-if>
<div id="button" class="style-scope utd-topbar-menu-button-renderer"></div>
</utd-topbar-menu-button-renderer>
`;
loginD.innerHTML = html;
})
} else{
console.log("user not logged in");
}
}
function loginFunction() {
const loginD = document.getElementById('login-icons');
const user = firebase.auth().currentUser;
if(user){
store.collection('c').doc(user.uid).get().then(doc => {
const html =
`
<utd-topbar-menu-button-renderer class="style-scope utd-masthead" use-keyboard-focused="">
<button id="avatar-btn" aria-haspopup="true" class="style-scope utd-topbar-menu-button-renderer" aria-label="Account profile photo">
<ut-img-shadow height="32" width="32" class="style-scope utd-topbar-menu-button-renderer no-transition" style="background-color: transparent;" loaded="">
<img id="img" href="/login.html" class="style-scope ut-img-shadow" alt="Avatar image" src="https://tallerthanshort.github.io/ut3.ggpht/icons/${doc.data().img}" width="32" height="32">
</ut-img-shadow>
</button>
<dom-if class="style-scope utd-topbar-menu-button-renderer">
<template is="dom-if"></template>
</dom-if>
<div id="button" class="style-scope utd-topbar-menu-button-renderer"></div>
</utd-topbar-menu-button-renderer>
`;
loginD.innerHTML = html;
})
} else{
location.href="/login.html"
}
}