Skip to content

Commit

Permalink
Updated Model_User::login()
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahdw committed Sep 5, 2009
1 parent 595c13b commit da05476
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions classes/model/auth/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ class Model_Auth_User extends ORM {
'username' => array
(
'not_empty' => NULL,
'min_length' => array(4),
'max_length' => array(32),
'regex' => array('![a-zA-Z0-9_.]!u'),
),
'password' => array
(
'not_empty' => NULL,
'min_length' => array(5),
'max_length' => array(42),
),
'password_confirm' => array
(
Expand Down Expand Up @@ -71,7 +66,7 @@ public function validate(array & $array, $save = FALSE)
{
// Set values
$this->values($array);

if ($save !== FALSE AND $status = $this->save())
{
if (is_string($save))
Expand All @@ -81,7 +76,7 @@ public function validate(array & $array, $save = FALSE)
}
}
}

return $status;
}

Expand All @@ -106,9 +101,9 @@ public function login(array & $array, $redirect = FALSE)
if ($array->check())
{
// Attempt to load the user
//$this->find($array['username']);
if (Auth::instance()->login($array['username'], $array['password']))
$this->where('username', '=', $array['username'])->find();

if (Auth::instance()->login($this, $array['password']))
{
if (is_string($redirect))
{
Expand Down Expand Up @@ -205,7 +200,7 @@ public function unique_key_exists($value)
->where($this->unique_key($value), '=', $value)
->execute($this->_db)
->count();

return (bool) $count;
}

Expand All @@ -215,10 +210,10 @@ public function unique_key_exists($value)
public function unique_key($id)
{
if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id))
{
{
return validate::email($id) ? 'email' : 'username';
}

return $this->_primary_key;
}

Expand Down

0 comments on commit da05476

Please sign in to comment.