From 99ab9df509d0dfbe1fc32075a629e2bd62ea8a2f Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Tue, 27 Jan 2015 11:07:41 +0100 Subject: [PATCH] Fixed a problem where user data of anonymous user is not loaded when a plugin uses the authorization api. Appdata authorization even now provides the userid. --- .../js/controllers/mediastreamcontroller.js | 26 ++++++++++++++++--- static/js/services/appdata.js | 7 ++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/static/js/controllers/mediastreamcontroller.js b/static/js/controllers/mediastreamcontroller.js index afc9da49..f02c45e7 100644 --- a/static/js/controllers/mediastreamcontroller.js +++ b/static/js/controllers/mediastreamcontroller.js @@ -408,10 +408,28 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder // Unmark authorization process. if (data.Userid) { - appData.authorizing(false); - } else if (!appData.authorizing()) { - // Trigger user data load when not in authorizing phase. - $scope.loadUserSettings(); + appData.authorizing(false, data.Userid); + } else { + if (!appData.authorizing()) { + // Trigger user data load when not in authorizing phase. + $scope.loadUserSettings(); + } else { + // Wait until authorizing is over and try it then. + var handler = (function() { + return function(event, authorizing, userid) { + if (!authorizing) { + // Turn of handler if we are no longer authorizing. + appData.e.off("authorizing", handler); + handler = null; + if (!userid) { + // Trigger user data load when without user after authorizing phase. + $scope.loadUserSettings(); + } + } + } + })(); + appData.e.on("authorizing", handler); + } } // Select room if settings have an alternative default room. diff --git a/static/js/services/appdata.js b/static/js/services/appdata.js index 2f4dc11d..9bcba939 100644 --- a/static/js/services/appdata.js +++ b/static/js/services/appdata.js @@ -40,8 +40,9 @@ define(["jquery"], function($) { // - mainStatus(event, status) // status (string) : Status id (connected, waiting, ...) // - // - authorizing(event, flag) + // - authorizing(event, flag, userid) // flag (bool) : True if authorizing phase, else false. + // userid (string) : User id if a user was authorized. // // - userSettingsLoaded(event, loaded, user_settings) // loaded (bool) : True if something was loaded, else false. @@ -74,13 +75,13 @@ define(["jquery"], function($) { service.data = d; return d; }; - service.authorizing = function(value) { + service.authorizing = function(value, userid) { // Boolean flag to indicate that an authentication is currently in progress. if (typeof(value) !== "undefined") { var v = !!value; if (v !== service.flags.authorizing) { service.flags.authorizing = v; - service.e.triggerHandler("authorizing", v); + service.e.triggerHandler("authorizing", v, userid); } } return service.flags.authorizing;