diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-26 15:43:35 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-26 15:43:35 +0200 |
| commit | 75aa163ccf407e9690f9ea0e548f8fed70073722 (patch) | |
| tree | dd68386a24c8c479149d094bb209fb0a78071c06 /state.go | |
| parent | a5d33f95ba68263e6c0ca758c5b854530332d9ae (diff) | |
OAuth: Add a Cancel method
Diffstat (limited to 'state.go')
| -rw-r--r-- | state.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -81,6 +81,20 @@ func (state *VPNState) Deregister() error { return nil } +func (state *VPNState) CancelOAuth() error { + if !state.FSM.InState(internal.OAUTH_STARTED) { + return errors.New("cannot cancel oauth, oauth not started") + } + + server, serverErr := state.Servers.GetCurrentServer() + + if serverErr != nil { + return serverErr + } + server.CancelOAuth() + return nil +} + func (state *VPNState) Connect(url string) (string, error) { if state.FSM.InState(internal.DEREGISTERED) { return "", errors.New("app not registered") @@ -99,6 +113,9 @@ func (state *VPNState) Connect(url string) (string, error) { loginErr := server.Login() if loginErr != nil { + // We are possibly in oauth started + // So go to chosen server + state.FSM.GoTransition(internal.CHOSEN_SERVER) return "", loginErr } } else { // OAuth was valid, ensure we are in the authenticated state |
