mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-11 19:06:20 +00:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
export default {
|
|
name: 'AppBar',
|
|
|
|
data: () => ({
|
|
drawyer: false,
|
|
isAdmin: false,
|
|
loggedIn: false
|
|
}),
|
|
created () {
|
|
this.getUserPreferences()
|
|
},
|
|
methods: {
|
|
home () {
|
|
this.$router.push('/')
|
|
},
|
|
account () {
|
|
this.$router.push('/account')
|
|
},
|
|
admin () {
|
|
this.$router.push('/admin')
|
|
},
|
|
logout () {
|
|
this.$http.get('/logout')
|
|
.then(response => {
|
|
if (response.status === 200) {
|
|
this.$router.push('/login')
|
|
}
|
|
})
|
|
},
|
|
checkForAdmin () {
|
|
this.loggedIn = false
|
|
this.drawyer = true
|
|
this.$http.get('/users/current')
|
|
.then(response => {
|
|
if (response.status === 200) {
|
|
this.loggedIn = true
|
|
this.isAdmin = response.data.user.isAdmin
|
|
}
|
|
})
|
|
.catch(() => {
|
|
this.isAdmin = false
|
|
})
|
|
},
|
|
getUserPreferences () {
|
|
this.$http.get('/users/current')
|
|
.then(response => {
|
|
if (response.status === 200) {
|
|
const preferences = response.data.user.preferences
|
|
this.$vuetify.theme.themes.dark.primary = preferences.accentColor.hex
|
|
this.$vuetify.theme.themes.light.primary = preferences.accentColor.hex
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|