ocket8888 commented on a change in pull request #3932: Rewrote 
/user/login/token to Go
URL: https://github.com/apache/trafficcontrol/pull/3932#discussion_r327205253
 
 

 ##########
 File path: traffic_ops/client/session.go
 ##########
 @@ -142,6 +156,29 @@ func (to *Session) login() (net.Addr, error) {
        return remoteAddr, nil
 }
 
+func (to *Session) loginWithToken(token []byte) (net.Addr, error) {
+       path := apiBase + "/user/login/token"
+       resp, remoteAddr, err := to.rawRequest(http.MethodPost, path, token)
+       resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
+       if err != nil {
+               return remoteAddr, fmt.Errorf("requesting: %v", err)
+       }
+       defer resp.Body.Close()
+
+       var alerts tc.Alerts
+       if err := json.NewDecoder(resp.Body).Decode(&alerts); err != nil {
+               return remoteAddr, fmt.Errorf("decoding response JSON: %v", err)
+       }
+
+       for _, alert := range alerts.Alerts {
 
 Review comment:
   Possibly. This is a copy of the logic from `loginWithAgent`, and I think a 
change to that logic should be global so that logging in always checks for 
success the same way.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to