From c77c817c9ea90d0c6479b9492f1069f1aaf140e5 Mon Sep 17 00:00:00 2001 From: laurenwalker Date: Wed, 31 May 2017 12:19:29 -0400 Subject: [PATCH] Add configurable uid and organization attributes to the AppModel. Turn off the profile settings for the default theme since it is not using tokens anymore. --- metacatui/src/main/webapp/js/models/AppModel.js | 2 ++ metacatui/src/main/webapp/js/models/UserModel.js | 6 ++++-- metacatui/src/main/webapp/js/themes/default/config.js | 1 + .../webapp/js/themes/default/templates/userProfileMenu.html | 0 metacatui/src/main/webapp/js/themes/knb/models/AppModel.js | 4 ++++ metacatui/src/main/webapp/js/views/RegistryView.js | 6 +++--- 6 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 metacatui/src/main/webapp/js/themes/default/templates/userProfileMenu.html diff --git a/metacatui/src/main/webapp/js/models/AppModel.js b/metacatui/src/main/webapp/js/models/AppModel.js index dc258f8ba..bbc56cb14 100644 --- a/metacatui/src/main/webapp/js/models/AppModel.js +++ b/metacatui/src/main/webapp/js/models/AppModel.js @@ -30,6 +30,8 @@ define(['jquery', 'underscore', 'backbone'], userProfiles: true, profileUsername: null, + ldapUidAttribute: "uid", + ldapOrgAttribute: "o", ldapDNSuffix: "dc=ecoinformatics,dc=org", useJsonp: true, diff --git a/metacatui/src/main/webapp/js/models/UserModel.js b/metacatui/src/main/webapp/js/models/UserModel.js index e9c572d99..565fe3a9e 100644 --- a/metacatui/src/main/webapp/js/models/UserModel.js +++ b/metacatui/src/main/webapp/js/models/UserModel.js @@ -351,8 +351,10 @@ define(['jquery', 'underscore', 'backbone', 'jws', 'models/Search', "collections if(!username) return; - if((username.indexOf("uid=") > -1) && (username.indexOf(",") > -1)) - fullName = username.substring(username.indexOf("uid=") + 4, username.indexOf(",")); + var ldapUidAttribute = appModel.get("ldapUidAttribute") || "uid" || ""; + + if((username.indexOf(ldapUidAttribute + "=") > -1) && (username.indexOf(",") > -1)) + fullName = username.substring(username.indexOf(ldapUidAttribute + "=") + 4, username.indexOf(",")); else if((username.indexOf("CN=") > -1) && (username.indexOf(",") > -1)) fullName = username.substring(username.indexOf("CN=") + 3, username.indexOf(",")); diff --git a/metacatui/src/main/webapp/js/themes/default/config.js b/metacatui/src/main/webapp/js/themes/default/config.js index 6f2ab73bd..7e6f9731a 100644 --- a/metacatui/src/main/webapp/js/themes/default/config.js +++ b/metacatui/src/main/webapp/js/themes/default/config.js @@ -6,5 +6,6 @@ var themeMap = // example overrides are provided here //'views/AboutView' : 'themes/' + theme + '/views/AboutView.js', //'templates/navbar.html' : 'themes/' + theme + '/templates/navbar.html' + "templates/userProfileMenu.html" : "themes/" + theme + "/templates/userProfileMenu.html" } }; \ No newline at end of file diff --git a/metacatui/src/main/webapp/js/themes/default/templates/userProfileMenu.html b/metacatui/src/main/webapp/js/themes/default/templates/userProfileMenu.html new file mode 100644 index 000000000..e69de29bb diff --git a/metacatui/src/main/webapp/js/themes/knb/models/AppModel.js b/metacatui/src/main/webapp/js/themes/knb/models/AppModel.js index 1044af6b2..a73b94efc 100644 --- a/metacatui/src/main/webapp/js/themes/knb/models/AppModel.js +++ b/metacatui/src/main/webapp/js/themes/knb/models/AppModel.js @@ -29,6 +29,10 @@ define(['jquery', 'underscore', 'backbone'], userProfiles: true, profileUsername: null, + + ldapUidAttribute: "uid", + ldapOrgAttribute: "o", + ldapDNSuffix: "dc=ecoinformatics,dc=org", useJsonp: true, diff --git a/metacatui/src/main/webapp/js/views/RegistryView.js b/metacatui/src/main/webapp/js/views/RegistryView.js index e184f2bf6..bd7080382 100644 --- a/metacatui/src/main/webapp/js/views/RegistryView.js +++ b/metacatui/src/main/webapp/js/views/RegistryView.js @@ -604,9 +604,9 @@ define(['jquery', 'underscore', 'backbone', 'bootstrap', 'jqueryform', 'views/Si return false; } - formObj.username.value = "uid=" + formObj.elements["uid"].value + ",o=" - + formObj.elements["organization"].value - + "," + appModel.get("ldapDNSuffix"); + formObj.username.value = appModel.get("ldapUidAttribute") + "=" + formObj.elements["uid"].value + + "," + appModel.get("ldapOrgAttribute") + "=" + formObj.elements["organization"].value + + "," + appModel.get("ldapDNSuffix"); // get the form data before replacing everything with the loading icon! var formData = $("#loginForm").serialize();