From 667508f25afda611e64ac8423d6ef0108fb51cec Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 14 Apr 2022 13:57:55 +0200 Subject: Simplify FSM by removing hierarchy --- src/oauth.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/oauth.go') diff --git a/src/oauth.go b/src/oauth.go index 8656979..836165a 100644 --- a/src/oauth.go +++ b/src/oauth.go @@ -227,7 +227,7 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { // It needs a vpn state that was gotten from `Register` // It returns the authurl for the browser and an error if present func (eduvpn *VPNState) InitializeOAuth() error { - if !eduvpn.HasTransition(SERVER_OAUTH_STARTED) { + if !eduvpn.HasTransition(OAUTH_STARTED) { return errors.New("Failed starting oauth, invalid state") } // Generate the state @@ -262,13 +262,13 @@ func (eduvpn *VPNState) InitializeOAuth() error { // Fill the struct with the necessary fields filled for the next call to getting the HTTP client oauthSession := &OAuthExchangeSession{ClientID: eduvpn.Name, State: state, Verifier: verifier} eduvpn.Server.OAuth = &OAuth{TokenURL: eduvpn.Server.Endpoints.API.V3.Token, Session: oauthSession} - eduvpn.GoTransition(SERVER_OAUTH_STARTED, authURL) + eduvpn.GoTransition(OAUTH_STARTED, authURL) return nil } // Error definitions func (eduvpn *VPNState) FinishOAuth() error { - if !eduvpn.HasTransition(SERVER_OAUTH_FINISHED) { + if !eduvpn.HasTransition(AUTHENTICATED) { return errors.New("invalid state to finish oauth") } oauth := eduvpn.Server.OAuth @@ -276,8 +276,7 @@ func (eduvpn *VPNState) FinishOAuth() error { if tokenErr != nil { return tokenErr } - eduvpn.GoTransition(SERVER_OAUTH_FINISHED, "") - eduvpn.GoTransition(SERVER_AUTHENTICATED, "") + eduvpn.GoTransition(AUTHENTICATED, "") return nil } -- cgit v1.2.3