From d0f4303ee5ccecc876fdfae1ce858369e3a323b7 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 2 May 2023 13:06:50 +0200 Subject: Client + FSM: Check transitions and add SetState Also make sure GotConfig can be used to go back to --- client/fsm.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'client/fsm.go') diff --git a/client/fsm.go b/client/fsm.go index 038e6cf..9c83b9b 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -98,12 +98,14 @@ func newFSM( Transitions: []FSMTransition{ {To: StateChosenLocation, Description: "Location chosen"}, {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateChosenLocation: FSMState{ Transitions: []FSMTransition{ {To: StateChosenServer, Description: "Server has been chosen"}, {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateLoadingServer: FSMState{ @@ -114,45 +116,54 @@ func newFSM( Description: "User chooses a Secure Internet server but no location is configured", }, {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateChosenServer: FSMState{ Transitions: []FSMTransition{ {To: StateAuthorized, Description: "Found tokens in config"}, {To: StateOAuthStarted, Description: "No tokens found in config"}, + {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateOAuthStarted: FSMState{ Transitions: []FSMTransition{ {To: StateAuthorized, Description: "User authorizes with browser"}, {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateAuthorized: FSMState{ Transitions: []FSMTransition{ {To: StateOAuthStarted, Description: "Re-authorize with OAuth"}, {To: StateRequestConfig, Description: "Client requests a config"}, - {To: StateNoServer, Description: "Client wants to go back to the main screen"}, + {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateRequestConfig: FSMState{ Transitions: []FSMTransition{ {To: StateAskProfile, Description: "Multiple profiles found and no profile chosen"}, {To: StateChosenProfile, Description: "Only one profile or profile already chosen"}, - {To: StateNoServer, Description: "Cancel or Error"}, {To: StateOAuthStarted, Description: "Re-authorize"}, + {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateAskProfile: FSMState{ Transitions: []FSMTransition{ {To: StateNoServer, Description: "Cancel or Error"}, {To: StateChosenProfile, Description: "Profile has been chosen"}, + {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateChosenProfile: FSMState{ Transitions: []FSMTransition{ - {To: StateNoServer, Description: "Cancel or Error"}, {To: StateGotConfig, Description: "Config has been obtained"}, + {To: StateNoServer, Description: "Go back or Error"}, + {To: StateGotConfig, Description: "Go back or Error"}, }, }, StateGotConfig: FSMState{ -- cgit v1.2.3