Skip to content

Commit

Permalink
adding new path channel to disconnect on bad response
Browse files Browse the repository at this point in the history
  • Loading branch information
cviecco committed Jun 1, 2022
1 parent 3ec3342 commit e203507
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/client/twofa/pushtoken/pushtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func doGenericPushCheck(client *http.Client,
baseURL string,
pushType string,
userAgentString string,
codeIsDone chan bool,
logger log.DebugLogger,
errorReturnDuration time.Duration) error {

Expand All @@ -118,7 +119,15 @@ func doGenericPushCheck(client *http.Client,
logger.Printf("") //To do a CR
return nil
}
time.Sleep(2 * time.Second)
select {
case codeSuccess := <-codeIsDone:
if codeSuccess {
return nil
}
continue
case <-time.After(2 * time.Second):
logger.Debugf(1, "doGenericPushCheck: timeout on checkGenericPollStatus loop")
}
}

err = errors.New("Vip Push Checked timeout out")
Expand Down Expand Up @@ -203,14 +212,19 @@ func doGenericTokenPushAuthenticate(

timeout := time.Duration(time.Duration(vipCheckTimeoutSecs) * time.Second)
ch := make(chan error, 1)
doneCh := make(chan bool, 1)
go func() {
err := genericAuthenticateWithToken(client, baseURL, pushType, userAgentString, logger)
if err == nil {
doneCh <- true
}
ch <- err
}()
go func() {
err := doGenericPushCheck(client, baseURL,
pushType,
userAgentString,
doneCh,
logger, timeout)
ch <- err

Expand Down

0 comments on commit e203507

Please sign in to comment.