diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-20 17:14:13 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-21 18:28:52 +0100 |
| commit | a8e71f7f20a1d5640d08ff637dc209206f536b8d (patch) | |
| tree | 3e0d2643befe839aadc586293387f2cf32a54d0e /client | |
| parent | b6c079587e035b073c32f52e537e253ae5a3f440 (diff) | |
Client + Exports: Forward tokens for /disconnect
Diffstat (limited to 'client')
| -rw-r--r-- | client/fsm.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/client/fsm.go b/client/fsm.go index c156fba..88f2cf9 100644 --- a/client/fsm.go +++ b/client/fsm.go @@ -2,6 +2,7 @@ package client import ( "github.com/eduvpn/eduvpn-common/internal/fsm" + "github.com/eduvpn/eduvpn-common/internal/oauth" "github.com/eduvpn/eduvpn-common/internal/server" "github.com/go-errors/errors" ) @@ -294,7 +295,7 @@ func (c *Client) SetDisconnecting() error { // This indicates that the VPN is currently disconnected from the server. // This also sends the /disconnect API call to the server. // Returns an error if this state transition is not possible. -func (c *Client) SetDisconnected(cleanup bool) error { +func (c *Client) SetDisconnected(cleanup bool, ct oauth.Token) error { if c.InFSMState(StateDisconnected) { // already disconnected, show no error c.Logger.Warningf("Already disconnected") @@ -312,8 +313,15 @@ func (c *Client) SetDisconnected(cleanup bool) error { } if cleanup { + // If we need to relogin, update tokens + if server.NeedsRelogin(srv) { + server.UpdateTokens(srv, ct) + } // Do the /disconnect API call and go to disconnected after... - server.Disconnect(srv) + err := server.Disconnect(srv) + if err != nil { + c.Logger.Warningf("Error disconnecting %v", err) + } } c.FSM.GoTransitionWithData(StateDisconnected, srv) |
