diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-04-12 22:55:16 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | a38e3e79f74e95051db7e14ae14ab817b68b725a (patch) | |
| tree | e26cab53f993d2d845020f81ee6f6f6a8a12ded1 /client/fsm.go | |
| parent | 4d228ba2084eb810d0cc33308893b00d1bb3eb02 (diff) | |
Refactor: Move client implementation to one file
Much easier to oversee and it forces me to keep the client type as
small as possible. This also uses the cookie for cancellation
We also no longer require tokens inside arguments. We will later
implement them with callbacks
Diffstat (limited to 'client/fsm.go')
| -rw-r--r-- | client/fsm.go | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/client/fsm.go b/client/fsm.go index 9f140e3..038e6cf 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -2,9 +2,6 @@ package client import ( "github.com/eduvpn/eduvpn-common/internal/fsm" - "github.com/eduvpn/eduvpn-common/internal/log" - "github.com/eduvpn/eduvpn-common/internal/server" - "github.com/go-errors/errors" ) type ( @@ -94,7 +91,6 @@ func newFSM( }, StateNoServer: FSMState{ Transitions: []FSMTransition{ - {To: StateNoServer, Description: "Reload list"}, {To: StateLoadingServer, Description: "User clicks a server in the UI"}, }, }, @@ -170,47 +166,3 @@ func newFSM( returnedFSM.Init(StateDeregistered, states, callback, directory, GetStateName, debug) return returnedFSM } - -// GoBack transitions the FSM back to the previous UI state, for now this is always the NO_SERVER state. -func (c *Client) GoBack() error { - if c.InFSMState(StateDeregistered) { - err := errors.Errorf("fsm attempt going back from 'StateDeregistered'") - c.logError(err) - return err - } - - // FIXME: Arbitrary back transitions don't work because we need the appropriate data - c.FSM.GoTransition(StateNoServer) - return nil -} - -// goBackInternal uses the public go back but logs an error if it happened. -func (c *Client) goBackInternal() { - err := c.GoBack() - if err != nil { - // TODO(jwijenbergh): Bit suspicious - logging level INFO, yet stacktrace logged. - log.Logger.Infof("failed going back: %s\nstacktrace:\n%s", err.Error(), err.(*errors.Error).ErrorStack()) - } -} - -// CancelOAuth cancels OAuth if one is in progress. -// If OAuth is not in progress, it returns an error. -// An error is also returned if OAuth is in progress, but it fails to cancel it. -func (c *Client) CancelOAuth() error { - if !c.InFSMState(StateOAuthStarted) { - return errors.Errorf("fsm attempt cancelling OAuth while in '%v'", c.FSM.Current) - } - - srv, err := c.Servers.GetCurrentServer() - if err != nil { - c.logError(err) - } else { - server.CancelOAuth(srv) - } - return err -} - -// InFSMState is a helper to check if the FSM is in state `checkState`. -func (c *Client) InFSMState(checkState FSMStateID) bool { - return c.FSM.InState(checkState) -} |
