From a0eba007750b737f26a54ad4ef4fa9ea0fb8f34c Mon Sep 17 00:00:00 2001
From: yvesn <yvesn>
Date: Tue, 30 May 2017 14:28:45 +0000
Subject: [PATCH] SSDM-5050 : ELN user profile - logging out automatically
 after save because the user information from the session needs to be reloaded

SVN: 38237
---
 .../1/as/webapps/eln-lims/html/js/server/ServerFacade.js  | 7 +++++--
 .../eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js | 5 +----
 .../html/js/views/UserProfile/UserProfileController.js    | 8 +++++---
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index b8dc40a0a66..8beaa46595e 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -104,8 +104,11 @@ function ServerFacade(openbisServer) {
 		this.openbisServer.ifRestoredSessionActive(callbackFunction);
 	}
 
-	this.logout = function(callbackFunction) {
-		this.openbisServer.logout(callbackFunction);
+	this.logout = function() {
+		$("#mainContainer").hide();
+		this.openbisServer.logout(function() {
+			location.reload();
+		});
 	}
 	
 	//
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
index 94357efec88..bb917914211 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
@@ -106,10 +106,7 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) {
         
         var logoutButton = FormUtil.getButtonWithIcon("glyphicon-off", function() {
         	$('body').addClass('bodyLogin');
-            mainController.serverFacade.logout(function(data) {
-                $("#login-form-div").show();
-                $("#mainContainer").hide();
-            });
+            mainController.serverFacade.logout();
         });
         
         var $searchForm = $("<form>", { "onsubmit": "return false;" })
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/UserProfile/UserProfileController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/UserProfile/UserProfileController.js
index 33f16328cbb..74c870c9621 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/UserProfile/UserProfileController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/UserProfile/UserProfileController.js
@@ -49,11 +49,13 @@ function UserProfileController(mainController, mode) {
 			return;
 		}
 		var userId = this._mainController.serverFacade.getUserId();
-		this._mainController.serverFacade.updateUserInformation(userId, userInformation, function(ok) {
+		this._mainController.serverFacade.updateUserInformation(userId, userInformation, (function(ok) {
 			if (ok) {
-				mainController.changeView("showUserProfilePage");
+				Util.showInfo("Profile saved. You will be logged out automatically in order to reload the profile data upon login.", (function() {
+					this._mainController.serverFacade.logout();
+				}).bind(this));
 			}
-		});
+		}).bind(this));
 	}
 
 	this._validate = function(userInformation) {
-- 
GitLab