2023-04-18 09:57:05 +04:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<p class='text-center m-3 h3'> Лабораторная работа 4</p>
|
|
|
|
</div>
|
|
|
|
<div>
|
2023-05-03 02:24:12 +04:00
|
|
|
<p class='h4 text-center' v-if="isAuthorized() == true">
|
|
|
|
<router-link to="/profiles" class="text-decoration-none m-3" v-if="isAdminFlag == true">Профили</router-link>
|
|
|
|
<router-link to="/" class="text-decoration-none m-3">Лента</router-link>
|
|
|
|
<a class="text-blue text-decoration-none" @click="logout">Выход</a>
|
2023-04-18 09:57:05 +04:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<router-view></router-view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-03 02:24:12 +04:00
|
|
|
import axios from 'axios'
|
2023-04-18 09:57:05 +04:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2023-05-03 02:24:12 +04:00
|
|
|
isAdminFlag: false
|
2023-04-18 09:57:05 +04:00
|
|
|
}
|
2023-05-03 02:24:12 +04:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
logout() {
|
|
|
|
localStorage.removeItem('user')
|
|
|
|
localStorage.removeItem('token')
|
|
|
|
location.reload()
|
|
|
|
},
|
|
|
|
isAuthorized() {
|
|
|
|
if (localStorage.getItem('token') != null) return true
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
async isAdmin() {
|
|
|
|
var a = await axios.get('http://localhost:8080/api/1.0/profile/role/' + localStorage.token,
|
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
'Authorization': 'Bearer ' + localStorage.token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
console.log('role')
|
|
|
|
console.log(a.data)
|
|
|
|
if (a.data == 'ADMIN') return true
|
|
|
|
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
var a = await axios.get('http://localhost:8080/api/1.0/profile/role/' + localStorage.token,
|
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
'Authorization': 'Bearer ' + localStorage.token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
console.log('role')
|
|
|
|
console.log(a.data)
|
|
|
|
if (a.data == 'ADMIN'){
|
|
|
|
this.isAdminFlag = true
|
|
|
|
}
|
|
|
|
},
|
2023-04-18 09:57:05 +04:00
|
|
|
}
|
2023-05-03 02:24:12 +04:00
|
|
|
|
2023-04-18 09:57:05 +04:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="">
|
|
|
|
|
|
|
|
</style>
|