native: fix token passtrough
This commit is contained in:
parent
8f9eb24c23
commit
7ac6d2adde
2 changed files with 15 additions and 3 deletions
|
@ -86,7 +86,7 @@ Rectangle {
|
|||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
var token = xhr.responseText.trim(); // Trim to remove any leading/trailing whitespace
|
||||
var token = xhr.responseText;
|
||||
loginSuccess(token);
|
||||
} else {
|
||||
console.log("Login failed: " + xhr.status);
|
||||
|
|
|
@ -32,7 +32,7 @@ Window {
|
|||
id: loginPageComponent
|
||||
LoginScreen {
|
||||
onLoginSuccess: function(token) {
|
||||
authToken = token;
|
||||
root.authToken = token;
|
||||
stackView.push(mainPageComponent);
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,22 @@ Window {
|
|||
Component {
|
||||
id: mainPageComponent
|
||||
MainPage {
|
||||
authToken: authToken
|
||||
id: mainPage
|
||||
authToken: root.authToken
|
||||
onLogout: {
|
||||
stackView.push(loginPageComponent)
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Update authToken when MainPage is created
|
||||
authToken = root.authToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAuthTokenChanged: {
|
||||
if (stackView.currentItem && stackView.currentItem.authToken !== undefined) {
|
||||
stackView.currentItem.authToken = authToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue