From 82e314259e280c3d198309c9b156bbbd46a00c7e Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 30 Jun 2008 11:54:46 +0000
Subject: [PATCH] login-feide: Changed to display error in template.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@723 44740490-163a-0410-bde0-09ae8108e29a
---
 attributealter/feideaccess.php        | 11 +++++++++--
 dictionaries/no_access_dictionary.php | 20 ++++++++++++++++++++
 templates/default/no_access.php       | 13 +++++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 dictionaries/no_access_dictionary.php
 create mode 100644 templates/default/no_access.php

diff --git a/attributealter/feideaccess.php b/attributealter/feideaccess.php
index 92132294e..e939c4303 100644
--- a/attributealter/feideaccess.php
+++ b/attributealter/feideaccess.php
@@ -20,10 +20,17 @@ function attributealter_feideaccess(&$attributes, $spEntityId = null, $idpEntity
 	$org = $org[1];
 
 	if(!in_array($org, $allowedOrgs, TRUE)) {
-		$session = SimpleSAML_Session::getInstance();
 		SimpleSAML_Logger::error('FEIDE access control: Organization "' . $org .
 			'" not in list of allowed organization for SP "' . $spEntityId . '".');
-		SimpleSAML_Utilities::fatalError($session->getTrackId(), 'NOACCESS');
+		$config = SimpleSAML_Configuration::getInstance();
+		$t = new SimpleSAML_XHTML_Template($config, 'no_access.php', 'no_access_dictionary.php');
+		if(array_key_exists('name', $spMetadata)) {
+			$t->data['sp_name'] = $spMetadata['name'];
+		} else {
+			$t->data['sp_name'] = $spEntityId;
+		}
+		$t->show();
+		exit();
 	}
 
 	SimpleSAML_Logger::info('FEIDE access control: Organization "' . $org .
diff --git a/dictionaries/no_access_dictionary.php b/dictionaries/no_access_dictionary.php
new file mode 100644
index 000000000..7edc186a2
--- /dev/null
+++ b/dictionaries/no_access_dictionary.php
@@ -0,0 +1,20 @@
+<?php
+
+$lang = array(
+	'access_denied' => array (
+		'da' => 'Du har ikke adgang til denne service',
+		'en' => 'You do not have access to this service',
+	),
+	'no_access_to' => array (
+		'da' => 'Du har ikke adgang til servicen:',
+		'en' => 'You do not have access to the service:',
+	),
+	'contact_home' => array (
+		'da' => 'Adgang til services bestemmes af din hjemmeorganisation. Kontakt venligst din lokale helpdesk for spørgsmål.',
+		'en' => 'Access to services is controlled by your home organization. Please contact your local it support for questions.',
+	),
+
+);
+
+
+?>
\ No newline at end of file
diff --git a/templates/default/no_access.php b/templates/default/no_access.php
new file mode 100644
index 000000000..44468a0a0
--- /dev/null
+++ b/templates/default/no_access.php
@@ -0,0 +1,13 @@
+<?php
+$this->data['header'] = $this->t('access_denied');
+$this->includeAtTemplateBase('includes/header.php');
+$this->includeInlineTranslation('spname', $this->data['sp_name']);
+?>
+<div id="content">
+		<h2><?php echo $this->t('access_denied');?></h2>
+		<p><?php echo $this->t('no_access_to');?></p>
+		<p><b><?php echo $this->t('spname');?></b></p>
+		<p><?php echo $this->t('contact_home');?></p>
+<?php
+$this->includeAtTemplateBase('includes/footer.php');
+?>
\ No newline at end of file
-- 
GitLab