From cead0f26b03999dd356d3dc1d04aafcc148b51db Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Sat, 22 May 2021 09:51:34 -0400 Subject: [PATCH] Fix token delay error during login --- resources/js/main.js | 14 +++++++------- resources/js/panel/panel.vue | 5 +++++ resources/js/panel/sidebar.vue | 5 +++++ resources/scss/main.scss | 6 ++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/resources/js/main.js b/resources/js/main.js index d67a15e..83def40 100644 --- a/resources/js/main.js +++ b/resources/js/main.js @@ -20,17 +20,17 @@ function getCookie(name) { return (value != null) ? unescape(value[1]) : null } -function getToken(app) { - fetch("/sanctum/csrf-cookie", { +function getToken() { + return fetch("/sanctum/csrf-cookie", { method: 'GET' }).then( () => { token = getCookie('XSRF-TOKEN') + return token }) - app.token = token } function login(event) { - fetch("/login", { + getToken().then(fetch("/login", { method: 'POST', headers: {'Content-Type': 'application/json', 'Accept': 'application/json', @@ -45,9 +45,9 @@ function login(event) { document.querySelector("#login_form .error").innerText = "Invalid credentials." } - }) + })) event.preventDefault() - event.stopPropogation() + // event.stopPropogation() } function getUser(app) { @@ -111,7 +111,7 @@ if (window.location.pathname == '/') { document.querySelector('#login_form button').addEventListener('click', login) const app = createApp(RegisterArea).mount('#app') // app.token = token - if (!token) {getToken(app)} + if (!token) {app.token = getToken()} //Triggers for registration menu for (let i = 0; i < registerToggles.length; i++) { diff --git a/resources/js/panel/panel.vue b/resources/js/panel/panel.vue index b34bfd4..0f3176e 100644 --- a/resources/js/panel/panel.vue +++ b/resources/js/panel/panel.vue @@ -59,8 +59,13 @@ + + +
+ +
diff --git a/resources/js/panel/sidebar.vue b/resources/js/panel/sidebar.vue index cef6589..f5af5f6 100644 --- a/resources/js/panel/sidebar.vue +++ b/resources/js/panel/sidebar.vue @@ -18,6 +18,11 @@ + + + + + diff --git a/resources/scss/main.scss b/resources/scss/main.scss index c98a514..919488f 100644 --- a/resources/scss/main.scss +++ b/resources/scss/main.scss @@ -821,6 +821,7 @@ main.panel { color: grey; height: 0; overflow: hidden; + transition: all 0.2s; } .selected .pending-content { @@ -843,6 +844,11 @@ main.panel { margin-bottom: 3px; margin-left: 2px; position: absolute; + transition: all 0.2s; + } + + .selected img { + transform: rotate(180deg); } }