Began implementing some kind of state machine for the login
This commit is contained in:
parent
61238c8d08
commit
7be33026cf
1 changed files with 30 additions and 1 deletions
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue