diff --git a/native/LoginScreen.qml b/native/LoginScreen.qml index 2bb5e59..a954a31 100644 --- a/native/LoginScreen.qml +++ b/native/LoginScreen.qml @@ -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); diff --git a/native/Main.qml b/native/Main.qml index cc4bd1d..38abf7c 100644 --- a/native/Main.qml +++ b/native/Main.qml @@ -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; } } }