Добавил подтягивание аватара юзера
This commit is contained in:
@@ -23,9 +23,9 @@
|
|||||||
button.header-buttons.flex.justify-center.items-center.mr-8.p-0
|
button.header-buttons.flex.justify-center.items-center.mr-8.p-0
|
||||||
.icon-bell.text-xxl
|
.icon-bell.text-xxl
|
||||||
.flex.justify-centflexer.items-center.relative
|
.flex.justify-centflexer.items-center.relative
|
||||||
//- base-avatar.mr-2(:size="36", :color="userData.color", v-if="!userData.photo") {{changeName}}
|
base-avatar.mr-2(:size="36", :color="userData?.color", v-if="!userData?.photo") {{changeName}}
|
||||||
//- base-avatar.mr-2(:size="32", v-else)
|
base-avatar.mr-2(:size="32", v-else)
|
||||||
//- img.h-full.object-cover(:src="url + userData.photo", alt="Avatar")
|
img.h-full.object-cover(:src="url + userData?.photo", alt="Avatar")
|
||||||
button.header-buttons(@click="openPopup")
|
button.header-buttons(@click="openPopup")
|
||||||
.icon-down-arrow.text-xxs.flex.justify-center.items-center.p-0
|
.icon-down-arrow.text-xxs.flex.justify-center.items-center.p-0
|
||||||
base-popup.right-2.top-10(
|
base-popup.right-2.top-10(
|
||||||
@@ -74,9 +74,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
changeName() {
|
changeName() {
|
||||||
return `${this.userData.last_name || ""} ${
|
return `${this.userData?.last_name || ""} ${
|
||||||
this.userData.first_name || ""
|
this.userData?.first_name || ""
|
||||||
} ${this.userData.patronymic || ""}`;
|
} ${this.userData?.patronymic || ""}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -84,29 +84,24 @@ export default {
|
|||||||
localStorage.username = this.user.username;
|
localStorage.username = this.user.username;
|
||||||
localStorage.password = this.user.password;
|
localStorage.password = this.user.password;
|
||||||
},
|
},
|
||||||
auth(token) {
|
async auth(token) {
|
||||||
fetch("http://45.84.227.122:8080/auth/users/me/", {
|
let res = await fetch("http://45.84.227.122:8080/auth/users/me/", {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
.then((res) => {
|
res = await res.json();
|
||||||
return res.json();
|
let data = await fetch(
|
||||||
})
|
`http://45.84.227.122:8080/accounts/users/${res.id}/detail`,
|
||||||
.then((data) => {
|
{
|
||||||
fetch(`http://45.84.227.122:8080/accounts/users/${data.id}/detail`, {
|
headers: {
|
||||||
headers: {
|
Authorization: `Bearer ${token}`,
|
||||||
Authorization: `Bearer ${token}`,
|
},
|
||||||
},
|
}
|
||||||
})
|
);
|
||||||
.then((res) => {
|
data = await data.json();
|
||||||
return res.json();
|
this.userData = data;
|
||||||
})
|
localStorage.setItem("userData", JSON.stringify(this.userData));
|
||||||
.then((data) => {
|
|
||||||
this.userData = data;
|
|
||||||
localStorage.setItem("userData", JSON.stringify(this.userData));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
login() {
|
login() {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
@@ -127,8 +122,7 @@ export default {
|
|||||||
.then((token) => {
|
.then((token) => {
|
||||||
if (token) {
|
if (token) {
|
||||||
localStorage.setItem("tokenAccess", token.access);
|
localStorage.setItem("tokenAccess", token.access);
|
||||||
this.$router.push("/");
|
this.auth(token.access).then(() => this.$router.push("/"));
|
||||||
this.auth(token.access);
|
|
||||||
} else {
|
} else {
|
||||||
this.$router.push("/login");
|
this.$router.push("/login");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user