summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/fsm.go10
-rw-r--r--internal/oauth.go3
-rw-r--r--internal/server.go2
3 files changed, 10 insertions, 5 deletions
diff --git a/internal/fsm.go b/internal/fsm.go
index fadc7c9..d0925c5 100644
--- a/internal/fsm.go
+++ b/internal/fsm.go
@@ -142,7 +142,7 @@ func (fsm *FSM) writeGraph() {
f.WriteString(graph)
}
-func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string) bool {
+func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string, background bool) bool {
ok := fsm.HasTransition(newState)
if ok {
@@ -151,14 +151,18 @@ func (fsm *FSM) GoTransitionWithData(newState FSMStateID, data string) bool {
if fsm.Debug {
fsm.writeGraph()
}
- fsm.StateCallback(oldState.String(), newState.String(), data)
+ if background {
+ go fsm.StateCallback(oldState.String(), newState.String(), data)
+ } else {
+ fsm.StateCallback(oldState.String(), newState.String(), data)
+ }
}
return ok
}
func (fsm *FSM) GoTransition(newState FSMStateID) bool {
- return fsm.GoTransitionWithData(newState, "")
+ return fsm.GoTransitionWithData(newState, "", false)
}
func (fsm *FSM) generateMermaidGraph() string {
diff --git a/internal/oauth.go b/internal/oauth.go
index 1e728ca..16edd1e 100644
--- a/internal/oauth.go
+++ b/internal/oauth.go
@@ -260,7 +260,8 @@ func (oauth *OAuth) start(name string, authorizationURL string, tokenURL string)
oauthSession := OAuthExchangeSession{ClientID: name, State: state, Verifier: verifier}
oauth.TokenURL = tokenURL
oauth.Session = oauthSession
- oauth.FSM.GoTransitionWithData(OAUTH_STARTED, authURL)
+ // Run the state callback in the background so that the user can login while we start the callback server
+ oauth.FSM.GoTransitionWithData(OAUTH_STARTED, authURL, true)
return nil
}
diff --git a/internal/server.go b/internal/server.go
index c76311e..48a0e85 100644
--- a/internal/server.go
+++ b/internal/server.go
@@ -170,7 +170,7 @@ func (server *Server) askForProfileID() error {
if !server.FSM.HasTransition(ASK_PROFILE) {
return errors.New("cannot ask for a profile id, invalid state")
}
- server.FSM.GoTransitionWithData(ASK_PROFILE, server.ProfilesRaw)
+ server.FSM.GoTransitionWithData(ASK_PROFILE, server.ProfilesRaw, false)
return nil
}