Bladeren bron

Fix token delay error during login

tags/v0.1.0
Immanuel Onyeka 3 jaren geleden
bovenliggende
commit
cead0f26b0
4 gewijzigde bestanden met toevoegingen van 23 en 7 verwijderingen
  1. +7
    -7
      resources/js/main.js
  2. +5
    -0
      resources/js/panel/panel.vue
  3. +5
    -0
      resources/js/panel/sidebar.vue
  4. +6
    -0
      resources/scss/main.scss

+ 7
- 7
resources/js/main.js Bestand weergeven

@@ -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++) {


+ 5
- 0
resources/js/panel/panel.vue Bestand weergeven

@@ -59,8 +59,13 @@
</tr>
</tbody>
</table>
<img class="nav-btn" src="../../images/arrow-left-circle-fill.svg" alt="">
<img class="nav-btn" src="../../images/arrow-right-circle-fill.svg" alt="">
</section>
</div>
<div d="main" v-else-if="active === '#exit'">
<div class="actions"><a class="new-order" href="#orders/new">New</a></div>
</div>
</transition>
</template>



+ 5
- 0
resources/js/panel/sidebar.vue Bestand weergeven

@@ -18,6 +18,11 @@
<path d="M3.5 11.5a3.5 3.5 0 1 1 3.163-5H14L15.5 8 14 9.5l-1-1-1 1-1-1-1 1-1-1-1 1H6.663a3.5 3.5 0 0 1-3.163 2zM2.5 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
</svg>
</a>
<a :class="{selected: active == '#exit'}" href="/panel#exit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-door-open-fill" viewBox="0 0 16 16">
<path d="M1.5 15a.5.5 0 0 0 0 1h13a.5.5 0 0 0 0-1H13V2.5A1.5 1.5 0 0 0 11.5 1H11V.5a.5.5 0 0 0-.57-.495l-7 1A.5.5 0 0 0 3 1.5V15H1.5zM11 2h.5a.5.5 0 0 1 .5.5V15h-1V2zm-2.5 8c-.276 0-.5-.448-.5-1s.224-1 .5-1 .5.448.5 1-.224 1-.5 1z"/>
</svg>
</a>
</nav>
</template>



+ 6
- 0
resources/scss/main.scss Bestand weergeven

@@ -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);
}
}



Laden…
Annuleren
Opslaan