Manage backend errors including expired sessions
diff --git a/ui-modules/utils/server-status/server-status.js b/ui-modules/utils/server-status/server-status.js
index 9d25c1a..2d97b17 100644
--- a/ui-modules/utils/server-status/server-status.js
+++ b/ui-modules/utils/server-status/server-status.js
@@ -55,7 +55,21 @@
let state = BrServerStatusModalController.STATES.OK;
let stateData = null;
if (error) {
- state = BrServerStatusModalController.STATES.NO_CONNECTION;
+ console.log(error);
+ 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 {
+ state = BrServerStatusModalController.STATES.OTHER_ERROR;
+ }
+
stateData = response;
} else {
stateData = response.data;
@@ -114,7 +128,11 @@
STOPPING: 'STOPPING',
NOT_HA_MASTER: 'NOT-HA-MASTER',
NO_CONNECTION: 'NO-CONNECTION',
- UNHEALTHY: 'UNHEALTHY'
+ UNHEALTHY: 'UNHEALTHY',
+ SESSION_INVALIDATED: 'SESSION_INVALIDATED',
+ SESSION_AGE_EXCEEDED: 'SESSION_AGE_EXCEEDED',
+ OTHER_ERROR: 'OTHER_ERROR',
+ USER_NOT_AUTHORIZED: 'USER_NOT_AUTHORIZED'
};
static $inject = ['$scope', '$uibModalInstance', 'state', 'stateData'];
diff --git a/ui-modules/utils/server-status/server-status.template.html b/ui-modules/utils/server-status/server-status.template.html
index eb54018..c9a692f 100644
--- a/ui-modules/utils/server-status/server-status.template.html
+++ b/ui-modules/utils/server-status/server-status.template.html
@@ -21,7 +21,9 @@
<h3 class="modal-title" ng-switch-when="STARTING">Server starting up…</h3>
<h3 class="modal-title" ng-switch-when="STOPPING">Server shutting down…</h3>
<h3 class="modal-title" ng-switch-when="NOT-HA-MASTER">This server is not the high availability master</h3>
- <h3 class="modal-title" ng-switch-when="NO-CONNECTION">Connecting to server…</h3>
+ <h3 class="modal-title" ng-switch-when="NO-CONNECTION|OTHER_ERROR" ng-switch-when-separator="|">Connecting to server…</h3>
+ <h3 class="modal-title" ng-switch-when="SESSION_INVALIDATED|SESSION_AGE_EXCEEDED" ng-switch-when-separator="|">Session invalid</h3>
+ <h3 class="modal-title" ng-switch-when="USER_NOT_AUTHORIZED">User not authorized</h3>
<h3 class="modal-title" ng-switch-when="OK">Server up and running</h3>
<h3 class="modal-title" ng-switch-default>This server has errors</h3>
</div>
@@ -75,6 +77,27 @@
<p>Your server has errors and is not healthy.</p>
<p>Please check with your system administrator.</p>
</div>
+ <div ng-switch-when="USER_NOT_AUTHORIZED">
+ <p>The current user is not authorized.</p>
+ <form action="/brooklyn-ui-logout" method="post">
+ <button type="submit" class="btn btn-success"><i class="fa fa-sign-out fa-fw"></i> Logout</button>
+ </form>
+ </div>
+ </div>
+ <div ng-switch-when="SESSION_INVALIDATED|SESSION_AGE_EXCEEDED" ng-switch-when-separator="|">
+ <p>Your last session has expired.</p>
+ <p>Please login again.</p>
+ <form action="/brooklyn-ui-logout" method="post">
+ <button type="submit" class="btn btn-success"><i class="fa fa-sign-out fa-fw"></i> Logout</button>
+ </form>
+ </div>
+ <div ng-switch-when="OTHER_ERROR">
+ <p>An unexpected error has occurred.</p>
+ <p>Please try to login again and if the problem persists, please check with your system administrator.</p>
+ <form action="/brooklyn-ui-logout" method="post">
+ <button type="submit" class="btn btn-success"><i class="fa fa-sign-out fa-fw"></i> Logout</button>
+ </form>
+ </div>
<div ng-switch-when="OK">
<p>The server is now ready to use.</p>
</div>