summaryrefslogtreecommitdiffstats
path: root/afb-client/app/Frontend/widgets
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2016-05-24 09:23:56 +0200
committerFulup Ar Foll <fulup@iot.bzh>2016-05-24 09:23:56 +0200
commit7b8fe1b305a36f925fc2757a2c126c88fb0a5137 (patch)
tree05623effa06276b7ccff95658f1a1dda01b48388 /afb-client/app/Frontend/widgets
parent35698424ab8973d91208df92471d18b1c901220e (diff)
Started move to new framework version
Diffstat (limited to 'afb-client/app/Frontend/widgets')
-rw-r--r--afb-client/app/Frontend/widgets/Notifications/TokenRefreshSvc.js26
1 files changed, 17 insertions, 9 deletions
diff --git a/afb-client/app/Frontend/widgets/Notifications/TokenRefreshSvc.js b/afb-client/app/Frontend/widgets/Notifications/TokenRefreshSvc.js
index 59fc763..ec29978 100644
--- a/afb-client/app/Frontend/widgets/Notifications/TokenRefreshSvc.js
+++ b/afb-client/app/Frontend/widgets/Notifications/TokenRefreshSvc.js
@@ -66,6 +66,13 @@ angular.module('TokenRefresh', ['AppConfig', 'ModalNotification'])
};
scope.onsuccess = function(jresp) {
+
+ if (jresp.request.status !== "success") {
+ Notification.warning ({message: jresp.request.info, delay: 5000});
+ scope.offline();
+ return;
+ }
+
if (jresp.request.token) AppConfig.session.token = jresp.request.token;
if (jresp.request.uuid) AppConfig.session.uuid = jresp.request.uuid;
if (jresp.request.timeout) AppConfig.session.timeout = jresp.request.timeout;
@@ -81,9 +88,9 @@ angular.module('TokenRefresh', ['AppConfig', 'ModalNotification'])
// Check Binder status
scope.getping = function() {
- AppCall.get ("token", "ping", {/*query*/},function(result) {
- if (result.status === 200) scope.onsuccess (result.data);
- else scope.onerror();
+ AppCall.get ("token", "ping", {/*query*/},function(jresp, errcode) {
+ if (errcode) scope.onerror();
+ else scope.onsuccess (jresp);
// restart a new timer for next ping
$timeout (scope.getping, AppConfig.session.pingrate*1000);
});
@@ -92,9 +99,9 @@ angular.module('TokenRefresh', ['AppConfig', 'ModalNotification'])
// Check Binder status
scope.refresh = function() {
- AppCall.get ("token", "refresh", {/*query*/},function(result) {
- if (result.status === 200) scope.onsuccess (result.data);
- else scope.onerror();
+ AppCall.get ("token", "refresh", {/*query*/},function(jresp, errcode) {
+ if (errcode) scope.onerror();
+ else scope.onsuccess (jresp);
// restart a new timer for next refresh
$timeout (scope.refresh, AppConfig.session.timeout *250);
});
@@ -103,9 +110,9 @@ angular.module('TokenRefresh', ['AppConfig', 'ModalNotification'])
// Initial connection
scope.tkcreate = function() {
- AppCall.get ("token", "create", {token: AppConfig.session.initial},function(result) {
- if (result.status === 200) scope.onsuccess (result.data);
- else scope.onerror();
+ AppCall.get ("token", "create", {token: AppConfig.session.initial},function(jresp, errcode) {
+ if (errcode) scope.onerror();
+ else scope.onsuccess (jresp);
});
};
@@ -133,3 +140,4 @@ angular.module('TokenRefresh', ['AppConfig', 'ModalNotification'])
})();
console.log ("Token Refresh Loaded");
+