[lux commit] r130 - trunk/Lux/Auth/Adapter

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 14, 2008, 10:12:36 AM4/14/08
to lux...@googlegroups.com
Author: anttih
Date: Mon Apr 14 07:12:18 2008
New Revision: 130

Modified:
trunk/Lux/Auth/Adapter/Psql.php

Log:
Lux_Auth_Adapter_Psql: [FIX] Now actually populates optional user
credentials. Thanks, Raymond Kolbe for the patch.


Modified: trunk/Lux/Auth/Adapter/Psql.php
==============================================================================
--- trunk/Lux/Auth/Adapter/Psql.php (original)
+++ trunk/Lux/Auth/Adapter/Psql.php Mon Apr 14 07:12:18 2008
@@ -135,7 +135,7 @@
$this->_redirect();
}
}
-
+
// if auth it not valid, processing is allowed and this is not
// a login attempt, try to login with cookie
if (! $this->isValid() && $this->allow && !
$this->isLoginRequest()) {
@@ -260,26 +260,41 @@
$select->from($this->_config['table'])
->cols($cols)
->where("{$this->_config['handle_col']} = ?", $handle)
- ->multiWhere($this->_config['where']);
+ ->multiWhere($this->_config['where'])
+ ->limit(2);

// fetch all
- $data = $select->fetch('all');
+ $rows = $select->fetchAll();

- // user that used a cookie was found in the real auth table.
- // fail authentication!
- if (count($data) != 1) {
+ // user that used a cookie was found in the real auth table
+ if (count($rows) == 1) {
+
+ // remove old token
+ $this->_deleteToken($token);
+
+ // make a new token and set the cookie
+ $this->_newCookie($handle);
+
+ // set base info
+ $info = array('handle' => $handle);
+
+ // set optional info from optional cols
+ $row = current($rows);
+ foreach ($optional as $key => $val) {
+ if ($this->_config[$val]) {
+ $info[$key] = $row[$this->_config[$val]];
+ }
+ }
+
+ // successful login, treat result as user info
+ $this->reset('VALID', $info);
+ return true;
+
+ } else {
+ // user that used a cookied was **not** found
+ // in the real auth table. fail authentication!
return false;
}
-
- // remove old token
- $this->_deleteToken($token);
-
- // make a new token and set the cookie
- $this->_newCookie($handle);
-
- // successful login, treat result as user info
- $this->reset('VALID', $data);
- return true;
}
}

@@ -404,4 +419,4 @@

return $identifier;
}
-}
\ No newline at end of file
+}

Reply all
Reply to author
Forward
0 new messages