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