cvs: pear /Auth Auth.php Container.php /Auth/Container DB.php
| From: | Martin Jansen | Date: | Tue, 20 Nov 2001 14:17:29 +0000 |
| Subject: | cvs: pear /Auth Auth.php Container.php /Auth/Container DB.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1385@lists.php.net to get a copy of this message | ||
mj Tue Nov 20 09:17:29 2001 EDT
Modified files:
/pear/Auth Auth.php Container.php
/pear/Auth/Container DB.php
Log:
* Rework the fetchData function for the DB container: When
the username is found in the database but the password is
wrong, the username is assigned to the variable $activeUser,
that is passed to the function that creates the login
screen. So this username can be set as the predefined
value for the input field "username" to signalize the user
that his username is right but the password is wrong.
Index: pear/Auth/Auth.php
diff -u pear/Auth/Auth.php:1.13 pear/Auth/Auth.php:1.14
--- pear/Auth/Auth.php:1.13 Tue Nov 20 05:56:58 2001
+++ pear/Auth/Auth.php Tue Nov 20 09:17:28 2001
@@ -16,7 +16,7 @@
// | Authors: Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Auth.php,v 1.13 2001/11/20 10:56:58 mj Exp $
+// $Id: Auth.php,v 1.14 2001/11/20 14:17:28 mj Exp $
//
@@ -48,7 +48,7 @@
*
* @author Martin Jansen <mj@php.net>
* @package Auth
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
define("AUTH_IDLED", -1);
@@ -231,7 +231,7 @@
}
if ($this->username == "" || !$login_ok) {
- $this->drawLogin();
+ $this->drawLogin($this->storage->activeUser);
return;
}
}
Index: pear/Auth/Container.php
diff -u pear/Auth/Container.php:1.5 pear/Auth/Container.php:1.6
--- pear/Auth/Container.php:1.5 Thu Nov 8 14:00:22 2001
+++ pear/Auth/Container.php Tue Nov 20 09:17:28 2001
@@ -16,7 +16,7 @@
// | Authors: Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Container.php,v 1.5 2001/11/08 19:00:22 mj Exp $
+// $Id: Container.php,v 1.6 2001/11/20 14:17:28 mj Exp $
//
define("AUTH_METHOD_NOT_SUPPORTED", -4);
@@ -30,6 +30,13 @@
class Auth_Container
{
+ /**
+ * User that is currently selected from the storage container.
+ *
+ * @access public
+ */
+ var $activeUser = "";
+
// {{{ Constructor
/**
@@ -56,6 +63,7 @@
function fetchData()
{
}
+
// }}}
// {{{ listUsers()
Index: pear/Auth/Container/DB.php
diff -u pear/Auth/Container/DB.php:1.8 pear/Auth/Container/DB.php:1.9
--- pear/Auth/Container/DB.php:1.8 Fri Nov 16 16:15:30 2001
+++ pear/Auth/Container/DB.php Tue Nov 20 09:17:29 2001
@@ -16,7 +16,7 @@
// | Authors: Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.8 2001/11/16 21:15:30 mj Exp $
+// $Id: DB.php,v 1.9 2001/11/20 14:17:29 mj Exp $
//
require_once "Auth/Container.php";
@@ -30,7 +30,7 @@
*
* @author Martin Jansen <mj@php.net>
* @package Auth
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
class Auth_Container_DB extends Auth_Container
{
@@ -47,6 +47,12 @@
*/
var $db = null;
+ /**
+ * User that is currently selected from the DB.
+ * @var string
+ */
+ var $activeUser = "";
+
// {{{ Constructor
/**
@@ -165,14 +171,11 @@
function fetchData($username, $password)
{
$query = sprintf("SELECT %s FROM %s
- WHERE %s = '%s'
- AND %s = '%s'",
- $this->options['usernamecol'],
+ WHERE %s = '%s'",
+ $this->options['usernamecol'] . ", " .
$this->options['passwordcol'],
$this->options['table'],
$this->options['usernamecol'],
- $this->db->quoteString($username),
- $this->options['passwordcol'],
- md5($password)
+ $this->db->quoteString($username)
);
$res = $this->db->query($query);
@@ -183,16 +186,22 @@
$entry = $res->FetchRow(DB_FETCHMODE_ASSOC);
if (is_array($entry)) {
- Auth::setAuth($entry[$this->options['usernamecol']]);
- $res->free();
-
- return true;
+ if ($entry[$this->options['passwordcol']] == md5($password)) {
+ Auth::setAuth($entry[$this->options['usernamecol']]);
+ $res->free();
+
+ return true;
+ } else {
+ $this->activeUser = $entry[$this->options['usernamecol']];
+ return false;
+ }
} else {
+ $this->activeUser = "";
return false;
}
}
}
-
+
// }}}
// {{{ listUsers()