summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/main.js37
1 files changed, 25 insertions, 12 deletions
diff --git a/web/main.js b/web/main.js
index 858408c..c0896b8 100644
--- a/web/main.js
+++ b/web/main.js
@@ -179,18 +179,29 @@ var guiHandlers = {
},
'saml_login': function samlLogin(session, message) {
- var samlData = null;
- performSamlAction('WaitLogin', {'sid': session.sid})
- .then(function (jsonObj) {
- if (jsonObj.code !== 0) return jsonObj;
- samlData = jsonObj.data;
- if (!samlData) return {'tid': message.tid, 'sid': message.sid, 'code': -2, 'message': 'IdP proxy did not return any SAML data'};
- if (!samlData.userData) return {'tid': message.tid, 'sid': message.sid, 'code': -3, 'message': 'IdP proxy did not return any SAML user data'};
- message.saml_data = samlData.userData; // add the data from SAML authentication, and forward everything to Python
- return sendDataToPython(message);
- })
- .then(function (jsonObj) {
- if (jsonObj.code === 0) session.samlData = samlData; // we need the SAML data to be able to perform global logout (saml_logout action)
+ var samlData = session.samlData,
+ p;
+ if (samlData && ('upgrade_account' in message)) {
+ message.saml_data = samlData.userData;
+ p = sendDataToPython(message);
+ }
+ else {
+ p = performSamlAction('WaitLogin', {'sid': session.sid})
+ .then(function (jsonObj) {
+ if (jsonObj.code !== 0) return jsonObj;
+ samlData = jsonObj.data;
+ if (!samlData) return {'tid': message.tid, 'sid': message.sid, 'code': -2, 'message': 'IdP proxy did not return any SAML data'};
+ if (!samlData.userData) return {'tid': message.tid, 'sid': message.sid, 'code': -3, 'message': 'IdP proxy did not return any SAML user data'};
+ message.saml_data = samlData.userData; // add the data from SAML authentication, and forward everything to Python
+ return sendDataToPython(message);
+ });
+ }
+
+ p.then(function (jsonObj) {
+ if ((jsonObj.code === 0) || (jsonObj.code === 1)) {
+ // we need the SAML data to be able to perform global logout (saml_logout action)
+ session.samlData = samlData;
+ }
session.send(jsonObj);
})
.catch(function (e) {
@@ -216,6 +227,8 @@ var guiHandlers = {
if (key !== 'userData') sd[key] = samlData[key];
}
+ delete session.samlData;
+
performSamlAction('WaitLogout', {'sid': session.sid, 'saml': JSON.stringify(sd)})
.then(function (jsonObj) {
if (jsonObj.code !== 0) return jsonObj;