From 60245c4f90f60dc7af79165cf074a4df57a02558 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 17 Aug 2014 03:48:28 +0100 Subject: implement html5 notifications. (have to be explicitly requested under Config) --- webclient/app-controller.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'webclient/app-controller.js') diff --git a/webclient/app-controller.js b/webclient/app-controller.js index 7fa87e30c1..ff4cb6e69e 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -45,6 +45,12 @@ angular.module('MatrixWebClientController', ['matrixService']) $scope.config = matrixService.config(); } }; + + $scope.closeConfig = function() { + if ($scope.config) { + $scope.config = undefined; + } + }; if (matrixService.config()) { eventStreamService.resume(); @@ -69,6 +75,15 @@ angular.module('MatrixWebClientController', ['matrixService']) console.log("Invalid access token -> log user out"); $scope.logout(); }); + + $scope.requestNotifications = function() { + if (window.Notification) { + console.log("Notification.permission: " + window.Notification.permission); + window.Notification.requestPermission(function(){}); + } + }; + + }]); -- cgit 1.5.1 From 0b5674ccc5e636249f0bf746a81af814dc4c8700 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Mon, 18 Aug 2014 10:44:29 +0200 Subject: Do not start the event stream if the user is not logged in (=if he does not has an access token yet) Add isUserLoggedIn to check this. --- webclient/app-controller.js | 2 +- webclient/app.js | 5 ++--- webclient/components/matrix/matrix-service.js | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'webclient/app-controller.js') diff --git a/webclient/app-controller.js b/webclient/app-controller.js index ff4cb6e69e..96656e12c3 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -52,7 +52,7 @@ angular.module('MatrixWebClientController', ['matrixService']) } }; - if (matrixService.config()) { + if (matrixService.isUserLoggedIn()) { eventStreamService.resume(); } diff --git a/webclient/app.js b/webclient/app.js index c4794e6abc..8d64db92d3 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -63,9 +63,8 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider', }]); matrixWebClient.run(['$location', 'matrixService', 'eventStreamService', function($location, matrixService, eventStreamService) { - // If we have no persistent login information, go to the login page - var config = matrixService.config(); - if (!config || !config.access_token) { + // If user auth details are not in cache, go to the login page + if (!matrixService.isUserLoggedIn()) { eventStreamService.stop(); $location.path("login"); } diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 0cc85db28e..c52c94c310 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -318,12 +318,21 @@ angular.module('matrixService', []) }; return doRequest("GET", path, params); }, - - // - testLogin: function() { - + + // Indicates if user authentications details are stored in cache + isUserLoggedIn: function() { + var config = this.config(); + + // User is considered logged in if his cache is not empty and contains + // an access token + if (config && config.access_token) { + return true; + } + else { + return false; + } }, - + /****** Permanent storage of user information ******/ // Returns the current config -- cgit 1.5.1