-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·73 lines (65 loc) · 1.47 KB
/
index.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
65
66
67
68
69
70
71
72
73
/* globals Vue, Vuetify, firebase */
const gAuthProvider = new firebase.auth.GoogleAuthProvider()
const admins = [
'Kpz3afszjBR0qwZYUrKURRJx2cm2', // Dylan
'g0G3A7FxieN333lZ2RKclkmv9Uw1' // Svante
]
firebase.firestore().enablePersistence()
const dateFormatter = new Intl.DateTimeFormat()
new Vue({
el: '#app',
vuetify: new Vuetify({
theme: {
themes: {
light: {
primary: '#fe3500',
secondary: '#ffc107',
accent: '#ffeb3b',
error: '#fe3500',
warning: '#ff9800',
info: '#3f51b5',
success: '#4caf50'
}
}
}
}),
data: () => ({
authDialog: 'unchecked',
uid: null,
drawer: false
}),
computed: {},
created () {
firebase.auth().onAuthStateChanged(user => {
if (user) {
if (admins.includes(user.uid)) {
this.authDialog = 'authed'
this.uid = user.uid
this.load()
} else {
this.uid = null
this.authDialog = 'notadmin'
}
} else {
this.authDialog = 'unchecked'
this.uid = null
}
})
},
methods: {
login () {
firebase.auth().signInWithPopup(gAuthProvider)
},
logout () {
firebase.auth().signOut()
}
},
filters: {
timestamp (value) {
if (!value) return ''
if (!(value instanceof firebase.firestore.Timestamp)) return value
const date = dateFormatter.format(value.toDate())
return date
}
}
})