added if-block for checking if user have cookie-files

This commit is contained in:
Kostya
2024-01-28 02:08:57 +03:00
parent 30686a2a5b
commit 44902ae7db

View File

@@ -18,6 +18,7 @@ export default {
logout() { logout() {
this.auth = false; this.auth = false;
this.balance = 0; this.balance = 0;
this.authtoken = ''
DeleteAllCookie(); DeleteAllCookie();
}, },
updateBalanceMethod() { updateBalanceMethod() {
@@ -32,6 +33,7 @@ export default {
return { return {
balance: 0, balance: 0,
auth: false, auth: false,
authtoken: '',
imageUrl: "https://avatar.spworlds.ru/face/55/", imageUrl: "https://avatar.spworlds.ru/face/55/",
userName: "", userName: "",
}; };
@@ -57,6 +59,7 @@ export default {
this.imageUrl = this.imageUrl + `${response.spUserName}.png`; this.imageUrl = this.imageUrl + `${response.spUserName}.png`;
this.userName = response.spUserName; this.userName = response.spUserName;
this.auth = true; this.auth = true;
this.authtoken = response.authtoken
GetCurrentMoney(GetCookie("AUTHTOKEN"), GetCookie("SearchToken")) GetCurrentMoney(GetCookie("AUTHTOKEN"), GetCookie("SearchToken"))
.then((response) => { .then((response) => {
this.balance = response.currentMoney; this.balance = response.currentMoney;
@@ -81,6 +84,7 @@ export default {
this.imageUrl = this.imageUrl + `${currentUserName}.png`; this.imageUrl = this.imageUrl + `${currentUserName}.png`;
this.userName = GetCookie("SpUserName"); this.userName = GetCookie("SpUserName");
this.auth = true; this.auth = true;
this.authtoken = GetCookie('AUTHTOKEN')
} else { } else {
this.auth = false; this.auth = false;
this.balance = 0; this.balance = 0;
@@ -102,6 +106,7 @@ export default {
this.imageUrl = this.imageUrl + `${currentUserName}.png`; this.imageUrl = this.imageUrl + `${currentUserName}.png`;
this.userName = GetCookie("SpUserName"); this.userName = GetCookie("SpUserName");
this.auth = true; this.auth = true;
this.authtoken = GetCookie('AUTHTOKEN')
} else { } else {
this.auth = false; this.auth = false;
this.balance = 0; this.balance = 0;
@@ -122,12 +127,12 @@ export default {
<div class="header__nav"> <div class="header__nav">
<nav> <nav>
<a href="#" @click="$router.push({ name: 'home' })" :class="{ 'header__nav--now' : $route.name === 'home' }">Главная</a> <a href="#" @click="$router.push({ name: 'home' })" :class="{ 'header__nav--now' : $route.name === 'home' }">Главная</a>
<a href="#" @click="$router.push({ name: 'profile' })" :class="{ 'header__nav--now' : $route.name === 'profile' }">Профиль</a> <a v-if="authtoken !== ''" href="#" @click="$router.push({ name: 'profile' })" :class="{ 'header__nav--now' : $route.name === 'profile' }">Профиль</a>
<a href="#">Помощь</a> <a href="#">Помощь</a>
</nav> </nav>
</div> </div>
<div class="header__balance"> <div class="header__balance">
<div class="header__content--balance"> <div class="header__content--balance" v-if="authtoken">
<div class="header__card--balance"> <div class="header__card--balance">
<h2> <h2>
<img src="../assets/icons-header/diamond-ore-icon.png" />{{ <img src="../assets/icons-header/diamond-ore-icon.png" />{{