Skip to content

Commit

Permalink
Server: Set OAuth endpoints on refresh
Browse files Browse the repository at this point in the history
This fixes OAuth endpoints after e.g. an update from 2.x to 3.x
  • Loading branch information
jwijenbergh committed Aug 29, 2023
1 parent ce637cb commit 88bcf43
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,23 @@ func HasValidProfile(srv Server, wireguardSupport bool) (bool, error) {

func RefreshEndpoints(srv Server) error {
// Re-initialize the endpoints
// TODO: Make this a warning instead?
b, err := srv.Base()
if err != nil {
return err
}

return b.InitializeEndpoints()
err = b.InitializeEndpoints()
if err != nil {
return err
}

// update OAuth
auth := srv.OAuth()
if auth != nil {
auth.BaseAuthorizationURL = b.Endpoints.API.V3.Authorization
auth.TokenURL = b.Endpoints.API.V3.Token
}
return nil
}

func Config(server Server, wireguardSupport bool, preferTCP bool) (*ConfigData, error) {
Expand Down

0 comments on commit 88bcf43

Please sign in to comment.