summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
Diffstat (limited to 'state.go')
-rw-r--r--state.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/state.go b/state.go
index 29f8a1e..8fbc7d2 100644
--- a/state.go
+++ b/state.go
@@ -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