tbouron commented on a change in pull request #159: Manage backend errors 
including expired sessions
URL: https://github.com/apache/brooklyn-ui/pull/159#discussion_r365318599
 
 

 ##########
 File path: ui-modules/utils/server-status/server-status.js
 ##########
 @@ -55,7 +56,28 @@ export function BrServerStatusDirective() {
             let state = BrServerStatusModalController.STATES.OK;
             let stateData = null;
             if (error) {
-                state = BrServerStatusModalController.STATES.NO_CONNECTION;
+                stateData = response.data;
+
+                if (stateData && stateData.SESSION_AGE_EXCEEDED) {
+                    state = 
BrServerStatusModalController.STATES.SESSION_AGE_EXCEEDED;
+                } else if (stateData && stateData.SESSION_INVALIDATED) {
+                    state = 
BrServerStatusModalController.STATES.SESSION_INVALIDATED;
+                }else if(response.status === 404) {
+                    state = BrServerStatusModalController.STATES.NO_CONNECTION;
+                }else if(response.status === 401 || response.status === 403 ) {
+                    state = 
BrServerStatusModalController.STATES.USER_NOT_AUTHORIZED;
+                }else {
+                    if (previousState === null || previousState == 
BrServerStatusModalController.STATES.OK){
+                        state = 
BrServerStatusModalController.STATES.OTHER_ERROR;
+                    } else {
+                        // we're now getting a new server error, possibly 
because the old error has expired
+                        // but changing the message for the user would be 
confusing so don't do that!
+                        // eg we get a 405 after a 307 (which the browser 
handles automatically) if redirected to Google for login
+                        console.log("Server responded \"" + stateData + "\" 
after previous problem \"" + previousState + "\"");
 
 Review comment:
   Could you use the `$log` service instead and make it `debug`? Can be 
injected in the controller on line 39

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to