[js-embedded-discovery] 01/04: EDS-73 Auto-follow on cookie: rationalize code
Rod Widdowson
rdw at steadingsoftware.com
Sat Mar 5 07:39:59 EST 2016
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository js-embedded-discovery.
commit 0ba4439e2434c11b3dbfe2c3d314d16617044c4b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Mar 4 12:03:58 2016 +0000
EDS-73 Auto-follow on cookie: rationalize code
https://issues.shibboleth.net/jira/browse/EDS-73
Separate out cookie finding code.
---
src/javascript/idpselect.js | 81 +++++++++++++++++++++++++++------------------
1 file changed, 49 insertions(+), 32 deletions(-)
diff --git a/src/javascript/idpselect.js b/src/javascript/idpselect.js
index 6f80ff5..73cb32b 100644
--- a/src/javascript/idpselect.js
+++ b/src/javascript/idpselect.js
@@ -1094,19 +1094,19 @@ function IdPSelectUI() {
return null;
}
for (i =0; i < idp.Logos.length; i++) {
- var logo = idp.Logos[i];
-
- if (logo.height == "16" && logo.width == "16") {
- if (null == logo.lang ||
- lang == logo.lang ||
- (typeof majorLang != 'undefined' && majorLang == logo.lang) ||
- defaultLang == logo.lang) {
- return logo.value;
- }
- }
- }
-
- return null;
+ var logo = idp.Logos[i];
+
+ if (logo.height == "16" && logo.width == "16") {
+ if (null == logo.lang ||
+ lang == logo.lang ||
+ (typeof majorLang != 'undefined' && majorLang == logo.lang) ||
+ defaultLang == logo.lang) {
+ return logo.value;
+ }
+ }
+ }
+
+ return null;
} ;
/**
@@ -1248,14 +1248,15 @@ function IdPSelectUI() {
userSelectedIdPs = newList;
return;
};
-
+
/**
- Gets the IdP previously selected by the user.
-
- @return {Array} user selected IdPs identified by their entity ID
+ Gets the value of the cookie with the provided name
+
+ @param (string) name - the name to look for
+ @return the value or null if no cookie of that name
*/
- var retrieveUserSelectedIdPs = function(){
- var userSelectedIdPs = [];
+
+ var getCookieCalled = function (name) {
var i, j;
var cookies;
@@ -1267,20 +1268,36 @@ function IdPSelectUI() {
var cookie = cookies[i];
var splitPoint = cookie.indexOf( '=' );
var cookieName = cookie.substring(0, splitPoint);
- var cookieValues = cookie.substring(splitPoint+1);
- if ( '_saml_idp' == cookieName.replace(/^\s+|\s+$/g, '') ) {
- cookieValues = cookieValues.replace(/^\s+|\s+$/g, '');
- cookieValues = cookieValues.replace('+','%20');
- cookieValues = cookieValues.split('%20');
- for(j=cookieValues.length; j > 0; j--){
- if (0 === cookieValues[j-1].length) {
- continue;
- }
- var dec = base64Decode(decodeURIComponent(cookieValues[j-1]));
- if (dec.length > 0) {
- userSelectedIdPs.push(dec);
- }
+ if ( name == ( cookieName.replace(/^\s+|\s+$/g, ''))) {
+ return cookie.substring(splitPoint+1);
+ }
+ }
+ return null;
+ }
+
+ /**
+ Gets the IdP previously selected by the user.
+
+ @return {Array} user selected IdPs identified by their entity ID
+ */
+ var retrieveUserSelectedIdPs = function(){
+ var userSelectedIdPs = [];
+ var j;
+
+ var cookieValues = getCookieCalled( '_saml_idp' );
+
+ if ( cookieValues != null) {
+ cookieValues = cookieValues.replace(/^\s+|\s+$/g, '');
+ cookieValues = cookieValues.replace('+','%20');
+ cookieValues = cookieValues.split('%20');
+ for(j=cookieValues.length; j > 0; j--){
+ if (0 === cookieValues[j-1].length) {
+ continue;
+ }
+ var dec = base64Decode(decodeURIComponent(cookieValues[j-1]));
+ if (dec.length > 0) {
+ userSelectedIdPs.push(dec);
}
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list