From 81aab13d04f3e774965ddbffe638ccede8656d7b Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 28 May 2008 08:35:45 +0000 Subject: login() can now be extended by other authentication methods. TODO: wrap this up with the PAM functionality. git-svn-id: https://code.elgg.org/elgg/trunk@727 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/sessions.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 20bf77850..cb3afc00a 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -27,18 +27,28 @@ } /** - * Log in + * Allows the user to log in. * - * @param string $username - * @param string $password - * @param true|false $persistent - * @return true|false + * This function can be extended with the 'user''login' plugin hook; + * any extension functions must return a user object. The extension function + * will be given any parameters to login() as an array. + * + * @param string $username The username, optionally (for standard logins) + * @param string $password The password, optionally (for standard logins) + * @param true|false $persistent Should the login be persistent? + * @return true|false Whether login was successful */ - function login($username, $password, $persistent = false) { + function login($username = "", $password = "", $persistent = false) { global $CONFIG; + + if ($user = trigger_plugin_hook('login','user',func_get_args(),false)) { + trigger_event('login','user',$user); + return true; + } + $dbpassword = md5($password); - + if ($user = get_user_by_username($username)) { if ($user->password == $dbpassword) { -- cgit v1.2.3