From a5fb3fc1cecdbd68e3d45ab98aeb99af620512df Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Fri, 23 Apr 2010 18:02:59 +0000
Subject: [PATCH] Automatically redirect to CAS when a user who isn't loged in
 attempts to register a new blog.

---
 unl.php | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/unl.php b/unl.php
index 23435cd..2b716bd 100644
--- a/unl.php
+++ b/unl.php
@@ -48,19 +48,23 @@ if (!function_exists('wp_validate_auth_cookie')) {
 }
 
 function unl_set_current_user()
-{   
+{
+	$auth = NULL;
     if (array_key_exists('unl_sso', $_COOKIE)) {
         $auth = phpCAS::checkAuthentication();
-        if ($auth) {
-            $username = phpCAS::getUser();
-            $user = new WP_User($username);
-            if (!$user->ID) {
-            	$user = unl_import_user($username);
-            	print_r($user);
-            }
-            setup_userdata($user->ID);
-            $GLOBALS['current_user'] = $user;
+    }
+    if ($GLOBALS['blogname'] == 'wp-signup.php') {
+    	$auth = phpCAS::forceAuthentication();
+    }
+    if ($auth) {
+        $username = phpCAS::getUser();
+        $user = new WP_User($username);
+        if (!$user->ID) {
+        	$user = unl_import_user($username);
+        	print_r($user);
         }
+        setup_userdata($user->ID);
+        $GLOBALS['current_user'] = $user;
     }
 }
 
-- 
GitLab