summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroenwijenbergh@protonmail.com>2022-04-19 12:56:57 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-19 12:56:57 +0200
commit42d2350e4a5d7a5bfb204bdc0994a0c283208fe7 (patch)
treeafa65e83d983c7d5c9015cf480f5155e704c278e
parentfb2f57cfcbb6408130e1cc75bd36c896502b78e0 (diff)
Config: Only write on deregister
-rw-r--r--src/api.go2
-rw-r--r--src/discovery.go2
-rw-r--r--src/oauth.go6
-rw-r--r--src/state.go4
4 files changed, 6 insertions, 8 deletions
diff --git a/src/api.go b/src/api.go
index 76631b1..1f058fc 100644
--- a/src/api.go
+++ b/src/api.go
@@ -16,7 +16,7 @@ func (server *Server) apiAuthenticated(method string, endpoint string, opts *HTT
}
url := server.Endpoints.API.V3.API + endpoint
- // Ensure we have non-expired tokens
+ // Ensure we have valid tokens
oauthErr := server.OAuth.EnsureTokens()
if oauthErr != nil {
diff --git a/src/discovery.go b/src/discovery.go
index e88d74e..4498779 100644
--- a/src/discovery.go
+++ b/src/discovery.go
@@ -107,7 +107,6 @@ func (eduvpn *VPNState) GetOrganizationsList() (string, error) {
}
eduvpn.EnsureDisco()
eduvpn.DiscoList.Organizations = &body
- eduvpn.WriteConfig()
return body, nil
}
@@ -123,6 +122,5 @@ func (eduvpn *VPNState) GetServersList() (string, error) {
}
eduvpn.EnsureDisco()
eduvpn.DiscoList.Servers = &body
- eduvpn.WriteConfig()
return body, nil
}
diff --git a/src/oauth.go b/src/oauth.go
index eb4e13f..831fa0f 100644
--- a/src/oauth.go
+++ b/src/oauth.go
@@ -292,15 +292,11 @@ func (state *VPNState) LoginOAuth() error {
if oauthErr != nil {
return oauthErr
}
-
- state.WriteConfig()
return nil
}
func (oauth *OAuth) Login() error {
- // FIXME: Find a better way
- state := GetVPNState()
- return state.LoginOAuth()
+ return GetVPNState().LoginOAuth()
}
func (oauth *OAuth) NeedsRelogin() bool {
diff --git a/src/state.go b/src/state.go
index 23bc1cd..1eb8ebd 100644
--- a/src/state.go
+++ b/src/state.go
@@ -61,6 +61,10 @@ func (state *VPNState) Deregister() error {
// Close the log file
state.CloseLog()
+ // Write the config
+ state.WriteConfig()
+
+ // Re-initialize the server and FSM
state.Server = &Server{}
state.InitializeFSM()
return nil