summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-19 15:42:54 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-19 15:42:54 +0200
commite78ab789220eb885985067457e1294488ac09ebc (patch)
tree5347ae70f900ec2a89ed7de26755ded9a5c4055d
parent5382a54af02d0a0aa6903192427930e25aef032c (diff)
Client: Set the current server also during adding
This fixes cancelling oauth
-rw-r--r--client/server.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/client/server.go b/client/server.go
index 468ff2e..dfdf132 100644
--- a/client/server.go
+++ b/client/server.go
@@ -255,6 +255,13 @@ func (client *Client) AddInstituteServer(url string) (server.Server, error) {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: serverErr}
}
+ // Set the server as the current so OAuth can be cancelled
+ currentErr := client.Servers.SetInstituteAccess(server)
+ if currentErr != nil {
+ client.goBackInternal()
+ return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: currentErr}
+ }
+
// Indicate that we want to authorize this server
client.FSM.GoTransition(STATE_CHOSEN_SERVER)
@@ -303,10 +310,18 @@ func (client *Client) AddSecureInternetHomeServer(orgID string) (server.Server,
locationErr := client.askSecureLocation()
if locationErr != nil {
// Removing is best effort
+ // This already goes back to the main screen
_ = client.RemoveSecureInternet()
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: locationErr}
}
+ // Set the server as the current so OAuth can be cancelled
+ currentErr := client.Servers.SetSecureInternet(server)
+ if currentErr != nil {
+ client.goBackInternal()
+ return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: currentErr}
+ }
+
// Server has been chosen for authentication
client.FSM.GoTransition(STATE_CHOSEN_SERVER)
@@ -346,6 +361,13 @@ func (client *Client) AddCustomServer(url string) (server.Server, error) {
return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: serverErr}
}
+ // Set the server as the current so OAuth can be cancelled
+ currentErr := client.Servers.SetCustomServer(server)
+ if currentErr != nil {
+ client.goBackInternal()
+ return nil, &types.WrappedErrorMessage{Message: errorMessage, Err: currentErr}
+ }
+
// Server has been chosen for authentication
client.FSM.GoTransition(STATE_CHOSEN_SERVER)