From 4b9f81c4844906ed2b67eefae4d577175d75f26c Mon Sep 17 00:00:00 2001 From: FEARmeR Date: Fri, 19 May 2023 14:11:50 +0100 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D0=B0=D1=83=D1=82=D0=B5=D0=BD=D1=82=D0=B8=D1=84=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20=D0=B6=D0=BE=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/LandingPages/SignIn/BasicView.vue | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/views/LandingPages/SignIn/BasicView.vue b/src/views/LandingPages/SignIn/BasicView.vue index 13f37ec..8a29f19 100644 --- a/src/views/LandingPages/SignIn/BasicView.vue +++ b/src/views/LandingPages/SignIn/BasicView.vue @@ -2,6 +2,7 @@ import { onMounted } from "vue"; import { ref } from "vue"; import axios from 'axios'; +import { computed } from "vue"; // example components import DefaultNavbar from "@/examples/navbars/NavbarDefault.vue"; @@ -14,6 +15,8 @@ const username = ref(''); const password = ref(''); const errorMessage = ref(''); +const isAuthenticated = computed(() => !!sessionStorage.getItem('access_token')); // Computed property to check if the user is authenticated + const login = async () => { if (!username.value || !password.value) { @@ -27,9 +30,11 @@ const login = async () => { username: username.value, password: password.value, }; + try { const response = await axios.post(url, body, { headers }); errorMessage.value = `Request:\nPOST ${url}\nHeaders: ${JSON.stringify(headers)}\nBody: ${JSON.stringify(body)}\n\nResponse:\nStatus: ${response.status}\nHeaders: ${JSON.stringify(response.headers)}\nBody: ${JSON.stringify(response.data)}`; + sessionStorage.setItem('access_token', response.data.access); // Save the access token in sessionStorage (new line) } catch (error) { if (error.response) { // The request was made and the server responded with a status code that falls out of the range of 2xx @@ -45,6 +50,10 @@ const login = async () => { } }; +const logout = () => { // Method to logout the user by clearing the session storage (new function) + sessionStorage.removeItem('access_token'); +}; + onMounted(() => { setMaterialInput(); @@ -106,6 +115,15 @@ export default {
+
+ +

Опять Ты!

+
+ +
+ +

Я вас не знаю, идите нафиг

+
@@ -124,6 +142,7 @@ export default { > Войти +
@@ -132,10 +151,7 @@ export default {
- - -

Нет аккаунта?