[Fusionforge-commits] r12741 - in trunk/src: common/include plugins plugins/authbuiltin plugins/authbuiltin/common plugins/authbuiltin/www www/account

Roland Mas lolando at fusionforge.org
Mon Mar 14 17:45:28 CET 2011


Author: lolando
Date: 2011-03-14 17:45:27 +0100 (Mon, 14 Mar 2011)
New Revision: 12741

Added:
   trunk/src/plugins/authbuiltin/
   trunk/src/plugins/authbuiltin/common/
   trunk/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php
   trunk/src/plugins/authbuiltin/common/authbuiltin-init.php
   trunk/src/plugins/authbuiltin/www/
   trunk/src/plugins/authbuiltin/www/post-login.php
Removed:
   trunk/src/common/include/BuiltinAuthPlugin.class.php
Modified:
   trunk/src/common/include/AuthPlugin.class.php
   trunk/src/common/include/RBACEngine.class.php
   trunk/src/common/include/pre.php
   trunk/src/common/include/session.php
   trunk/src/www/account/login.php
   trunk/src/www/account/logout.php
Log:
Implemented basic functions for an AuthBuiltin plugin

Modified: trunk/src/common/include/AuthPlugin.class.php
===================================================================
--- trunk/src/common/include/AuthPlugin.class.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/common/include/AuthPlugin.class.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -22,9 +22,9 @@
  * USA
  */
 
-define(FORGE_AUTH_AUTHORITATIVE_ACCEPT, 1);
-define(FORGE_AUTH_AUTHORITATIVE_REJECT, 2);
-define(FORGE_AUTH_NOT_AUTHORITATIVE, 3);
+define('FORGE_AUTH_AUTHORITATIVE_ACCEPT', 1);
+define('FORGE_AUTH_AUTHORITATIVE_REJECT', 2);
+define('FORGE_AUTH_NOT_AUTHORITATIVE', 3);
 
 abstract class AuthPlugin extends Plugin {
 	/**
@@ -78,25 +78,22 @@
 
 	// Default mechanisms
 	protected $saved_user;
-	function checkAuthSession($params) {
+	function checkAuthSession(&$params) {
 		if (isset($params['auth_token']) && $params['auth_token'] != '') {
-			$user = $this->checkSessionToken($params['auth_token']);
+			$user_id = $this->checkSessionToken($params['auth_token']);
 		} else {
-			$user = $this->checkSessionCookie();
+			$user_id = $this->checkSessionCookie();
 		}
-		if ($user) {
-			$this->saved_user = $user;
+		if ($user_id) {
+			$this->saved_user = user_get_object($user_id);
+			$params['results'][$this->name] = FORGE_AUTH_AUTHORITATIVE_ACCEPT;
 		} else {
 			$this->saved_user = NULL;
-		}
-		if ($user) {
-			$params['results'][$this->name] = FORGE_AUTH_AUTHORITATIVE_ACCEPT;
-		} else {
 			$params['results'][$this->name] = FORGE_AUTH_NOT_AUTHORITATIVE;
 		}
 	}
 
-	function fetchAuthUser($params) {
+	function fetchAuthUser(&$params) {
 		$params['results'] = $this->saved_user;
 	}
 
@@ -104,6 +101,14 @@
 		$this->unsetSessionCookie();
 	}
 
+	function getExtraRoles(&$params) {
+		// $params['new_roles'][] = RBACEngine::getInstance()->getRoleById(123);
+	}
+	
+	function restrictRoles(&$params) {
+		// $params['dropped_roles'][] = RBACEngine::getInstance()->getRoleById(123);
+	}
+	
 	// Helper functions for individual plugins
 	protected $cookie_name = 'session_ser';
 
@@ -117,7 +122,7 @@
 	}
 
 	protected function setSessionCookie() {
-		$cookie = session_build_session_cookie($user_id);
+		$cookie = session_build_session_cookie($this->saved_user->getID());
 		session_cookie($this->cookie_name, $cookie, "", forge_get_config('session_expire'));
 	}
 

Deleted: trunk/src/common/include/BuiltinAuthPlugin.class.php
===================================================================
--- trunk/src/common/include/BuiltinAuthPlugin.class.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/common/include/BuiltinAuthPlugin.class.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -1,77 +0,0 @@
-<?php
-/**
- * FusionForge authentication management
- *
- * Copyright 2011, Roland Mas
- *
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- * 
- * FusionForge is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-abstract class BuiltinAuthPlugin extends AuthPlugin {
-	/**
-	 * BuiltinAuthPlugin() - constructor
-	 *
-	 */	
-	function BuiltinAuthPlugin() {
-		$this->AuthPlugin();
-		$this->_addHook('check_auth_session');
-		$this->_addHook('fetch_authenticated_user');
-		$this->_addHook('display_auth_form');
-		// display_create_user_form - display a form to create a user from external auth
-		// fetch_account_info - sync identity from external source (realname, email, etc.)
-		// get_extra_roles - add new roles not necessarily stored in the database
-		// restrict_roles - filter out unwanted roles
-		$this->_addHook('close_auth_session');
-	}
-	
-	function displayAuthForm($params) {
-		$return_to = $params['return_to'];
-		$loginname = '';
-
-		$this->_displayAuthForm($return_to, $login_name);
-	}
-
-	function _displayAuthForm($return_to, $login_name) {
-		if (session_issecure()) {
-			$login_button = _('Login with SSL');
-		} else {
-			$login_button = _('Login'); 
-		}
-
-		echo '<form action="' . util_make_url('/plugins/builtinauth/postlogin.php'); . '" method="post">
-<input type="hidden" name="form_key" value="' . form_generate_key() . '"/>
-<input type="hidden" name="return_to" value="' . htmlspecialchars(stripslashes($return_to)) . '" />
-<p>';
-		if (forge_get_config('require_unique_email')) {
-			echo _('Login name or email address');
-		} else {
-			echo _('Login name:');
-		}
-		echo '<br /><input type="text" name="form_loginname" value="' . htmlspecialchars(stripslashes($login_name)) . '" /></p><p>' . _('Password:') . '<br /><input type="password" name="form_pw" /></p><p><input type="submit" name="login" value="' . $login_button . '" />
-</p>
-</form>' ;
-	}
-
-}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
-
-?>

Modified: trunk/src/common/include/RBACEngine.class.php
===================================================================
--- trunk/src/common/include/RBACEngine.class.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/common/include/RBACEngine.class.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -75,9 +75,47 @@
 			}
 		}
 		
+		$params = array();
+		$params['current_roles'] = $this->_cached_available_roles;
+		$params['new_roles'] = array();
+		plugin_hook_by_reference('get_extra_roles', $params);
+		foreach ($params['new_roles'] as $r) {
+			$this->addAvailableRole($r);
+		}
+		
+		$params = array();
+		$params['current_roles'] = $this->_cached_available_roles;
+		$params['dropped_roles'] = array();
+		plugin_hook_by_reference('restrict_roles', $params);
+		foreach ($params['dropped_roles'] as $r) {
+			$this->dropAvailableRole($r);
+		}
+		
 		return $this->_cached_available_roles ;
 	}
 
+	private function addAvailableRole($role) {
+		$seen = false;
+		foreach ($this->_cached_available_roles as $r) {
+			if ($r->getID() == $role->getID()) {
+				$seen = true;
+			}
+		}
+		if (!$seen) {
+			$this->_cached_available_roles[] = $role;
+		}
+	}
+
+	private function dropAvailableRole($role) {
+		$new_roles = array();
+		foreach ($this->_cached_available_roles as $r) {
+			if ($r->getID() != $role->getID()) {
+				$new_roles[] = $r;
+			}
+		}
+		$this->_cached_available_roles = $new_roles;
+	}
+
 	public function getGlobalRoles() {
 		if ($this->_cached_global_roles != NULL) {
 			return $this->_cached_global_roles ;

Modified: trunk/src/common/include/pre.php
===================================================================
--- trunk/src/common/include/pre.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/common/include/pre.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -182,6 +182,9 @@
 	// SCM-specific plugins subsystem
 	require_once $gfcommon.'include/SCMPlugin.class.php' ;
 	
+	// Authentication-specific plugins subsystem
+	require_once $gfcommon.'include/AuthPlugin.class.php' ;
+
 	if (getenv ('FUSIONFORGE_NO_PLUGINS') != 'true') {
 		setup_plugin_manager () ;
 	}
@@ -252,6 +255,7 @@
 	setup_gettext_from_context();
 }
 
+
 /*
 RESERVED VARIABLES
 

Modified: trunk/src/common/include/session.php
===================================================================
--- trunk/src/common/include/session.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/common/include/session.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -73,6 +73,9 @@
  *	@return user_id if cookie is ok, false otherwise
  */
 function session_check_session_cookie($session_cookie) {
+	if ($session_cookie == '') {
+		return false;
+	}
 
 	list ($session_serial, $hash) = explode('-*-', $session_cookie);
 	$session_serial = base64_decode($session_serial);
@@ -108,12 +111,7 @@
  *
  */
 function session_logout() {
-
-	// delete both session and username cookies
-	// NB: cookies must be deleted with the same scope parameters they were set with
-	//
-	session_cookie('session_ser', '');
-
+	plugin_hook('close_auth_session');
 	RBACEngine::getInstance()->invalidateRoleCaches() ;
 	return true;
 }
@@ -155,7 +153,11 @@
 	return session_login_valid_dbonly ($loginname, $passwd, $allowpending) ;
 }
 
-function session_login_valid_dbonly ($loginname, $passwd, $allowpending) {
+function session_login_valid_dbonly($loginname, $passwd, $allowpending=false) {
+	return session_check_credentials_in_database($loginname, $passwd, $allowpending);
+}
+
+function session_check_credentials_in_database($loginname, $passwd, $allowpending=false) {
 	global $feedback,$userstatus;
 
 	//  Try to get the users from the database using user_id and (MD5) user_pw
@@ -200,7 +202,7 @@
 			$res = db_query_params ('UPDATE users SET user_pw=$1 WHERE user_id=$2',
 						array (md5($passwd),
 						       $usr['user_id'])) ;
-			return session_login_valid_dbonly($loginname, $passwd, $allowpending) ;
+			return session_check_credentials_in_database($loginname, $passwd, $allowpending) ;
 		}
 	} else {
 		// If we're here, then the user has typed a password matching the (MD5) user_pw
@@ -216,7 +218,7 @@
 				$res = db_query_params ('UPDATE users SET unix_pw=$1 WHERE user_id=$2',
 							array (account_genunixpw($passwd),
 							       $usr['user_id'])) ;
-				return session_login_valid_dbonly($loginname, $passwd, $allowpending) ;
+				return session_check_credentials_in_database($loginname, $passwd, $allowpending) ;
 			} else {
 				// Invalidate (MD5) user_pw, refuse authentication
 				$res = db_query_params ('UPDATE users SET user_pw=$1 WHERE user_id=$2',
@@ -543,8 +545,8 @@
 	$params = array();
 	$params['auth_token'] = $session_ser;
 	$params['results'] = array();
-	plugin_hook('check_auth_session');
-	
+	plugin_hook_by_reference('check_auth_session', $params);
+
 	$seen_yes = false;
 	$seen_no = false;
 	foreach ($params['results'] as $p => $r) {
@@ -560,8 +562,8 @@
 
 	$params = array();
 	$params['results'] = NULL;
-	plugin_hook('fetch_authenticated_user');
-	
+	plugin_hook_by_reference('fetch_authenticated_user', $params);
+
 	$G_SESSION = $params['results'];
 	if ($G_SESSION) {
 		$G_SESSION->setLoggedIn(true);
@@ -575,7 +577,8 @@
 		}
 	}
 
-	RBACEngine::getInstance()->invalidateRoleCaches() ;
+	$re = RBACEngine::getInstance();
+	$re->invalidateRoleCaches() ;
 }
 
 //TODO - this should be generalized and used for pre.php, 

Copied: trunk/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php (from rev 12740, trunk/src/common/include/BuiltinAuthPlugin.class.php)
===================================================================
--- trunk/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php	                        (rev 0)
+++ trunk/src/plugins/authbuiltin/common/AuthBuiltinPlugin.class.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -0,0 +1,81 @@
+<?php
+/**
+ * FusionForge authentication management
+ *
+ * Copyright 2011, Roland Mas
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+class AuthBuiltinPlugin extends AuthPlugin {
+	/**
+	 * AuthBuiltinPlugin() - constructor
+	 *
+	 */	
+	function AuthBuiltinPlugin() {
+		$this->AuthPlugin();
+		$this->name = 'authbuiltin';
+		$this->text = 'Built-in authentication';
+		$this->_addHook('check_auth_session');
+		$this->_addHook('fetch_authenticated_user');
+		$this->_addHook('display_auth_form');
+		// display_create_user_form - display a form to create a user from external auth
+		// fetch_account_info - sync identity from external source (realname, email, etc.)
+		// get_extra_roles - add new roles not necessarily stored in the database
+		// restrict_roles - filter out unwanted roles
+		$this->_addHook('close_auth_session');
+	}
+
+	function displayAuthForm($params) {
+		$return_to = $params['return_to'];
+		$loginname = '';
+
+		$this->_displayAuthForm($return_to, $login_name);
+	}
+
+	function _displayAuthForm($return_to, $login_name) {
+		echo '<form action="' . util_make_url('/plugins/authbuiltin/post-login.php') . '" method="post">
+<input type="hidden" name="form_key" value="' . form_generate_key() . '"/>
+<input type="hidden" name="return_to" value="' . htmlspecialchars(stripslashes($return_to)) . '" />
+<p>';
+		if (forge_get_config('require_unique_email')) {
+			echo _('Login name or email address');
+		} else {
+			echo _('Login name:');
+		}
+		echo '<br /><input type="text" name="form_loginname" value="' . htmlspecialchars(stripslashes($login_name)) . '" /></p><p>' . _('Password:') . '<br /><input type="password" name="form_pw" /></p><p><input type="submit" name="login" value="' . _('Login') . '" />
+</p>
+</form>' ;
+	}
+
+	function login($user) {
+		$this->saved_user = $user;
+		$this->setSessionCookie();
+	}
+
+	function logout() {
+		$this->unsetSessionCookie();
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/src/plugins/authbuiltin/common/authbuiltin-init.php
===================================================================
--- trunk/src/plugins/authbuiltin/common/authbuiltin-init.php	                        (rev 0)
+++ trunk/src/plugins/authbuiltin/common/authbuiltin-init.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -0,0 +1,36 @@
+<?php
+/** FusionForge plugin for authentication
+ *
+ * Copyright 2011, Roland Mas
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ * 
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+global $gfplugins;
+require_once $gfplugins.'authbuiltin/common/AuthBuiltinPlugin.class.php' ;
+
+$AuthBuiltinPluginObject = new AuthBuiltinPlugin ;
+
+register_plugin ($AuthBuiltinPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/src/plugins/authbuiltin/www/post-login.php
===================================================================
--- trunk/src/plugins/authbuiltin/www/post-login.php	                        (rev 0)
+++ trunk/src/plugins/authbuiltin/www/post-login.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -0,0 +1,169 @@
+<?php
+/**
+ * FusionForge login page
+ *
+ * This is main login page. It takes care of different account states
+ * (by disallowing logging in with non-active account, with appropriate
+ * notice).
+ *
+ * Copyright 1999-2001 (c) VA Linux Systems
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+Header( "Expires: Wed, 11 Nov 1998 11:11:11 GMT"); 
+Header( "Cache-Control: no-cache"); 
+Header( "Cache-Control: must-revalidate"); 
+
+require_once('../../../www/env.inc.php');
+require_once $gfcommon.'include/pre.php';
+
+$plugin = plugin_get_object('authbuiltin');
+
+$return_to = getStringFromRequest('return_to');
+$login = getStringFromRequest('login');
+$form_loginname = getStringFromRequest('form_loginname');
+$form_pw = getStringFromRequest('form_pw');
+$feedback = htmlspecialchars(getStringFromRequest('feedback'));
+$warning_msg = htmlspecialchars(getStringFromRequest('warning_msg'));
+$error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
+$triggered = getIntFromRequest('triggered');
+
+//
+//	Validate return_to
+//
+if ($return_to) {
+	$tmpreturn=explode('?',$return_to);
+	$rtpath = $tmpreturn[0] ;
+
+	if (@is_file(forge_get_config('url_root').$rtpath)
+	    || @is_dir(forge_get_config('url_root').$rtpath)
+	    || (strpos($rtpath,'/projects') == 0)
+	    || (strpos($rtpath,'/plugins/mediawiki') == 0)) {
+		$newrt = $return_to ;
+	} else {
+		$newrt = '/' ;
+	}
+	$return_to = $newrt ;
+}
+
+if (forge_get_config('use_ssl') && !session_issecure()) {
+	//force use of SSL for login
+	header('Location: https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
+}
+
+// ###### first check for valid login, if so, redirect
+
+if ($login) {
+	if (!form_key_is_valid(getStringFromRequest('form_key'))) {
+		exit_form_double_submit();
+	}
+	$success = session_check_credentials_in_database(strtolower($form_loginname),$form_pw,false);
+	if ($success) {
+		error_log ('Login form passed OK');
+		$plugin->login(user_get_object_by_name($form_loginname));
+		if ($return_to) {
+			header ("Location: " . util_make_url($return_to));
+			exit;
+		} else {
+			header ("Location: " . util_make_url("/my"));
+			exit;
+		}
+	} else {
+		if ($form_loginname && $form_pw) {
+			$warning_msg = _('Invalid Password Or User Name');
+		} else {
+			$warning_msg = _('Missing Password Or Users Name');
+		}
+		
+	}
+}
+
+if (isset($session_hash)) {
+	//nuke their old session
+	session_logout();
+}
+
+$HTML->header(array('title'=>'Login'));
+
+if ($login && !$success) {
+	form_release_key(getStringFromRequest('form_key'));	
+	// Account Pending
+	if (!isset($userstatus)) {
+		if (isset ($form_loginname)) {
+			$u = user_get_object_by_name($form_loginname) || 
+				user_get_object_by_email($form_loginname) ;
+			if (!$u) {
+				$warning_msg .= '<br /><p>'. _('Your account does not exist.').'</p>';
+			}
+		}
+	} else if ($userstatus == "P") {
+		$warning_msg .= '<br />'. sprintf(_('<p>Your account is currently pending your email confirmation.		Visiting the link sent to you in this email will activate your account.		<p>If you need this email resent, please click below and a confirmation		email will be sent to the email address you provided in registration.		<p><a href="%1$s">[Resend Confirmation Email]</a>		<br><hr>		<p>'), util_make_url ("/account/pending-resend.php?form_user=".htmlspecialchars($form_loginname)));
+	} else {
+		if ($userstatus == "D") {
+			$error_msg .= '<br />'.sprintf(_('<p>Your %1$s account has been removed by %1$s staff. This may occur for two reasons, either 1) you requested that your account be removed; or 2) some action has been performed using your account which has been seen as objectionable (i.e. you have breached the terms of service for use of your account) and your account has been revoked for administrative reasons. Should you have questions or concerns regarding this matter, please log a <a href="%2$s">support request</a>.</p><p>Thank you, <br><br>%1$s Staff</p>'), forge_get_config ('forge_name'), util_make_url ("/support/?group_id=1"));
+		}
+	}
+	html_error_top($error_msg);
+	html_warning_top($warning_msg);
+	html_feedback_top($feedback);
+}
+
+echo '<p>';
+
+echo _('Cookies must be enabled past this point.');
+
+?>
+</p>
+<form action="<?php echo util_make_url('/plugins/authbuiltin/post-login.php'); ?>" method="post">
+<input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
+<input type="hidden" name="return_to" value="<?php echo htmlspecialchars(stripslashes($return_to)); ?>" />
+<p>
+<?php if (forge_get_config('require_unique_email')) {
+	echo _('Login name or email address');
+} else {
+	echo _('Login name:');
+} ?>
+<br /><input type="text" name="form_loginname" value="<?php echo htmlspecialchars(stripslashes($form_loginname)); ?>" />
+</p>
+<p>
+<?php echo _('Password:'); ?>
+<br /><input type="password" name="form_pw" />
+</p>
+<p>
+<input type="submit" name="login" value="<?php echo _('Login'); ?>" />
+</p>
+</form>
+<p><a href="lostpw.php"><?php echo _('[Lost your password?]'); ?></a></p>
+<?php
+// hide "new account" item if restricted to admin
+if (!forge_get_config ('user_registration_restricted')) {
+	echo '<p><a href="register.php">'._('[New Account]').'</a></p>';
+}
+?>
+<p><a href="pending-resend.php"><?php echo _('[Resend confirmation email to a pending account]'); ?></a></p>
+
+<?php
+
+$HTML->footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Modified: trunk/src/www/account/login.php
===================================================================
--- trunk/src/www/account/login.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/www/account/login.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -33,65 +33,8 @@
 require_once $gfcommon.'include/pre.php';
 
 $return_to = getStringFromRequest('return_to');
-$login = getStringFromRequest('login');
-$form_loginname = getStringFromRequest('form_loginname');
-$form_pw = getStringFromRequest('form_pw');
-$feedback = htmlspecialchars(getStringFromRequest('feedback'));
-$warning_msg = htmlspecialchars(getStringFromRequest('warning_msg'));
-$error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
 $triggered = getIntFromRequest('triggered');
 
-//
-//	Validate return_to
-//
-if ($return_to) {
-	$tmpreturn=explode('?',$return_to);
-	$rtpath = $tmpreturn[0] ;
-
-	if (@is_file(forge_get_config('url_root').$rtpath)
-	    || @is_dir(forge_get_config('url_root').$rtpath)
-	    || (strpos($rtpath,'/projects') == 0)
-	    || (strpos($rtpath,'/plugins/mediawiki') == 0)) {
-		$newrt = $return_to ;
-	} else {
-		$newrt = '/' ;
-	}
-	$return_to = $newrt ;
-}
-
-if (forge_get_config('use_ssl') && !session_issecure()) {
-	//force use of SSL for login
-	header('Location: https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
-}
-
-// Decide login button based on session.
-if (session_issecure()) {
-    $login_button = _('Login with SSL');
-} else {
-    $login_button = _('Login'); 
-}
-
-// ###### first check for valid login, if so, redirect
-
-if ($login) {
-	if (!form_key_is_valid(getStringFromRequest('form_key'))) {
-		exit_form_double_submit();
-	}
-	$success=session_login_valid(strtolower($form_loginname),$form_pw);
-	if ($success) {
-		/*
-			You can now optionally stay in SSL mode
-		*/
-		if ($return_to) {
-			header ("Location: " . util_make_url($return_to));
-			exit;
-		} else {
-			header ("Location: " . util_make_url("/my"));
-			exit;
-		}
-	}
-}
-
 if (isset($session_hash)) {
 	//nuke their old session
 	session_logout();
@@ -99,29 +42,6 @@
 
 $HTML->header(array('title'=>'Login'));
 
-if ($login && !$success) {
-	form_release_key(getStringFromRequest('form_key'));	
-	// Account Pending
-	if (!isset($userstatus)) {
-		if (isset ($form_loginname)) {
-			$u = user_get_object_by_name($form_loginname) || 
-				user_get_object_by_email($form_loginname) ;
-			if (!$u) {
-				$warning_msg .= '<br /><p>'. _('Your account does not exist.').'</p>';
-			}
-		}
-	} else if ($userstatus == "P") {
-		$warning_msg .= '<br />'. sprintf(_('<p>Your account is currently pending your email confirmation.		Visiting the link sent to you in this email will activate your account.		<p>If you need this email resent, please click below and a confirmation		email will be sent to the email address you provided in registration.		<p><a href="%1$s">[Resend Confirmation Email]</a>		<br><hr>		<p>'), util_make_url ("/account/pending-resend.php?form_user=".htmlspecialchars($form_loginname)));
-	} else {
-		if ($userstatus == "D") {
-			$error_msg .= '<br />'.sprintf(_('<p>Your %1$s account has been removed by %1$s staff. This may occur for two reasons, either 1) you requested that your account be removed; or 2) some action has been performed using your account which has been seen as objectionable (i.e. you have breached the terms of service for use of your account) and your account has been revoked for administrative reasons. Should you have questions or concerns regarding this matter, please log a <a href="%2$s">support request</a>.</p><p>Thank you, <br><br>%1$s Staff</p>'), forge_get_config ('forge_name'), util_make_url ("/support/?group_id=1"));
-		}
-	}
-	html_error_top($error_msg);
-	html_warning_top($warning_msg);
-	html_feedback_top($feedback);
-}
-
 echo '<p>';
 
 if ($triggered) {
@@ -130,28 +50,10 @@
 	echo '</div> ' ;
 }
 echo _('Cookies must be enabled past this point.');
+echo '</p>';
 
+plugin_hook('display_auth_form');
 ?>
-</p>
-<form action="<?php echo util_make_url('/account/login.php'); ?>" method="post">
-<input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
-<input type="hidden" name="return_to" value="<?php echo htmlspecialchars(stripslashes($return_to)); ?>" />
-<p>
-<?php if (forge_get_config('require_unique_email')) {
-	echo _('Login name or email address');
-} else {
-	echo _('Login name:');
-} ?>
-<br /><input type="text" name="form_loginname" value="<?php echo htmlspecialchars(stripslashes($form_loginname)); ?>" />
-</p>
-<p>
-<?php echo _('Password:'); ?>
-<br /><input type="password" name="form_pw" />
-</p>
-<p>
-<input type="submit" name="login" value="<?php echo $login_button; ?>" />
-</p>
-</form>
 <p><a href="lostpw.php"><?php echo _('[Lost your password?]'); ?></a></p>
 <?php
 // hide "new account" item if restricted to admin

Modified: trunk/src/www/account/logout.php
===================================================================
--- trunk/src/www/account/logout.php	2011-03-14 16:45:12 UTC (rev 12740)
+++ trunk/src/www/account/logout.php	2011-03-14 16:45:27 UTC (rev 12741)
@@ -53,8 +53,6 @@
 
 session_logout();
 
-plugin_hook('before_logout_redirect');
-
 if ($return_to) {
 	header('Location: '.util_make_url ($return_to));
 }else{




More information about the Fusionforge-commits mailing list