From 7be33026cf51011db25b6cfb7ec2780b7f78b0ef Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Mon, 27 Jan 2020 18:36:43 +0100 Subject: [PATCH] Began implementing some kind of state machine for the login --- qml/pages/LoginPage.qml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/qml/pages/LoginPage.qml b/qml/pages/LoginPage.qml index 936c3c8..a48f441 100644 --- a/qml/pages/LoginPage.qml +++ b/qml/pages/LoginPage.qml @@ -6,6 +6,18 @@ Page { id: loginPage property string accountId + /* Possible states for loginStatus: + - newAccount: No information about the account is known yet + - unknownLoggedOut: The user is logged out and the server version is not known + - unknownLoggedIn: The user is logged in but the server version is not known + - legacyLoggedOut: The user is logged out and the server does not accept Login Flow V2 + - legacyPending: The user has provided his credentials but they are not verified yet + - legacyLoggedIn: The user has provided his credentials and they have been accepted by the server + - flowV2LoggedOut: The user is logged out and the server does support Login Flow V2 + - flowV2Pending: The user has initiated the Login Flow V2 workflow + - flowV2LoggedIn: The Login Flow V2 workflow has been successfully finished + */ + property string loginStatus: "unknownLoggedOut" ConfigurationGroup { id: account @@ -33,10 +45,27 @@ Page { console.log("Nextcloud instance found") } } + onStatusVersionChanged: { + if (notesApi.statusVersion.split('.')[0] < 16) { + if (loginStatus === "unknownLoggedOut") + loginStatus = "legacyLoggedOut" + if (loginStatus === "unknownLoggedIn") + loginStatus = "legacyLoggedIn" + } + if (notesApi.statusVersion.split('.')[0] >= 16) { + if (loginStatus === "unknownLoggedOut") + loginStatus = "flowV2LoggedOut" + if (loginStatus === "unknownLoggedIn") + loginStatus = "flowV2LoggedIn" + } + } onLoginUrlChanged: { - if (notesApi.loginUrl) + if (notesApi.loginUrl) { + loginStatus = "flowV2Pending" Qt.openUrlExternally(notesApi.loginUrl) + } else { + loginStatus = "flowV2LoggedIn" console.log("Login successfull") } }