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