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 {
- - -

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