From eaae2297887204d50b5b288b775a03573d4ab00c Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Wed, 8 Sep 2010 07:04:29 +0000
Subject: [PATCH] IdPDisco: Allow override of saving the last IdP chosen.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2531 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XHTML/IdPDisco.php | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index b8e9c285c..88775555d 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -351,6 +351,19 @@ class SimpleSAML_XHTML_IdPDisco {
 	}
 
 
+	/**
+	 * Save the current IdP choice to a cookie.
+	 *
+	 * @param string $idp  The entityID of the IdP.
+	 */
+	protected function setPreviousIdP($idp) {
+		assert('is_string($idp)');
+
+		$this->log('Choice made [' . $idp . '] Setting cookie.');
+		$this->setCookie('lastidp', $idp);
+	}
+
+
 	/**
 	 * Determine whether the choice of IdP should be saved.
 	 *
@@ -380,9 +393,7 @@ class SimpleSAML_XHTML_IdPDisco {
 		$idp = $this->getSelectedIdP();
 		if($idp !== NULL) {
 			/* The user selected this IdP. Save the choice in a cookie. */
-
-			$this->log('Choice made [' . $idp . '] Setting cookie.');
-			$this->setCookie('lastidp', $idp);
+			$this->setPreviousIdP($idp);
 
 			if($this->saveIdP()) {
 				$this->setCookie('remember', 1);
-- 
GitLab