parent
ffae1c2ed7
commit
a6118791b1
2 changed files with 22 additions and 20 deletions
|
@ -71,25 +71,27 @@ Rectangle {
|
||||||
|
|
||||||
text: qsTr("Submit")
|
text: qsTr("Submit")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: login
|
||||||
var xhr = new XMLHttpRequest();
|
}
|
||||||
xhr.open("POST", "https://api.clan-war.net/api/v1/auth/login");
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/json");
|
function login() {
|
||||||
xhr.onreadystatechange = function() {
|
var xhr = new XMLHttpRequest();
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
xhr.open("POST", "https://api.clan-war.net/api/v1/auth/login");
|
||||||
if (xhr.status === 200) {
|
xhr.setRequestHeader("Content-Type", "application/json");
|
||||||
var token = xhr.responseText.trim(); // Trim to remove any leading/trailing whitespace
|
xhr.onreadystatechange = function() {
|
||||||
loginSuccess(token);
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||||
} else {
|
if (xhr.status === 200) {
|
||||||
console.log("Login failed: " + xhr.status);
|
var token = xhr.responseText.trim(); // Trim to remove any leading/trailing whitespace
|
||||||
}
|
loginSuccess(token);
|
||||||
|
} else {
|
||||||
|
console.log("Login failed: " + xhr.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data = JSON.stringify({
|
|
||||||
email: nameT.text,
|
|
||||||
password: passwordT.text
|
|
||||||
});
|
|
||||||
xhr.send(data);
|
|
||||||
}
|
}
|
||||||
|
var data = JSON.stringify({
|
||||||
|
email: nameT.text,
|
||||||
|
password: passwordT.text
|
||||||
|
});
|
||||||
|
xhr.send(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ Window {
|
||||||
Component {
|
Component {
|
||||||
id: loginPageComponent
|
id: loginPageComponent
|
||||||
LoginScreen {
|
LoginScreen {
|
||||||
onLoginSuccess: {
|
onLoginSuccess: function(token) {
|
||||||
authToken = token
|
authToken = token;
|
||||||
stackView.push(mainPageComponent)
|
stackView.push(mainPageComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue