From a6af942424baf9325d93e850dd7caf34873f2ed5 Mon Sep 17 00:00:00 2001
From: Juan Ferrer Toribio <juan.ferrer.toribio@gmail.com>
Date: Mon, 15 Jan 2018 09:24:15 +0100
Subject: [PATCH] Supplant bugs solved

---
 debian/changelog |  2 +-
 js/hedera/gui.js | 17 +++++++++++++++--
 package.json     |  2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fe467a77..f5bf8847 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-hedera-web (1.405.65) stable; urgency=low
+hedera-web (1.405.66) stable; urgency=low
 
   * Initial Release.
 
diff --git a/js/hedera/gui.js b/js/hedera/gui.js
index 4b98622f..b097a645 100644
--- a/js/hedera/gui.js
+++ b/js/hedera/gui.js
@@ -88,6 +88,8 @@ module.exports = new Class
 			localStorage.setItem ('hederaCookies', true);
 			Htk.Toast.showWarning (_('By using this site you accept cookies'));
 		}
+
+		this.supplantInit ();
 	}
 	
 	,hide: function ()
@@ -512,17 +514,26 @@ module.exports = new Class
 	
 	//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant
 	
+	,supplantInit: function ()
+	{
+		var user = sessionStorage.getItem ('supplantUser');
+
+		if (user != null)
+			this.supplantUser (user);
+	}
+
 	,supplantUser: function (user, callback)
 	{
 		this._conn.supplantUser (user,
-			this._onUserSupplant.bind (this, callback));
+			this._onUserSupplant.bind (this, callback, user));
 	}
 	
-	,_onUserSupplant: function (callback, supplantOk)
+	,_onUserSupplant: function (callback, user, supplantOk)
 	{
 		if (!supplantOk)
 			return;
 	
+		sessionStorage.setItem ('supplantUser', user);
 		this.loadMenu ();
 	
 		var sql = 'SELECT nickname FROM account.userView';
@@ -543,6 +554,8 @@ module.exports = new Class
 	{
 		Vn.Node.hide (this.$('supplant'));
 		this._conn.supplantEnd ();
+		sessionStorage.removeItem ('supplantUser',
+			sessionStorage.getItem ('supplantUser'));
 		this.loadMenu ();
 		this._onFormChange ();
 	}
diff --git a/package.json b/package.json
index 5e071a3e..ac38d638 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "hedera-web",
-  "version": "1.405.65",
+  "version": "1.405.66",
   "description": "Verdnatura web page",
   "license": "GPL-3.0",
   "repository": {