summaryrefslogtreecommitdiff
path: root/internal/api.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-09 14:18:23 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-09 14:18:23 +0200
commit1ef27cc47ad56a2c66aaa40e398a0063be2573d4 (patch)
treefff365577d82274f2b05878e702238b8a575c5c8 /internal/api.go
parentfd0753c5463b4c54d09712336301e174f05e05ab (diff)
FSM/State: Profile correctness and connect name change
Also add a force tcp flag
Diffstat (limited to 'internal/api.go')
-rw-r--r--internal/api.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/api.go b/internal/api.go
index a987f00..b615976 100644
--- a/internal/api.go
+++ b/internal/api.go
@@ -24,8 +24,12 @@ func apiAuthorized(server Server, method string, endpoint string, opts *HTTPOpti
url := base.Endpoints.API.V3.API + endpoint
// Ensure we have valid tokens
+ stateBefore := base.FSM.Current
oauthErr := EnsureTokens(server)
+ // we reset the state so that we go from the authorized state to the state we want
+ base.FSM.Current = stateBefore
+
if oauthErr != nil {
return nil, nil, oauthErr
}
@@ -83,7 +87,11 @@ func APIInfo(server Server) error {
if baseErr != nil {
return &APIInfoError{Err: baseErr}
}
+
+ // Store the profiles and make sure that the current profile is not overwritten
+ previousProfile := base.Profiles.Current
base.Profiles = structure
+ base.Profiles.Current = previousProfile
base.ProfilesRaw = string(body)
return nil
}