Dropped Redis model, rebuilt without it
The model was getting a bit more complicated than I would have liked. Went back to using straight redis commands and moved some of the user model logic into the custommodule.
This commit is contained in:
parent
2c5144f026
commit
c1817a24be
13 changed files with 69 additions and 198 deletions
|
@ -16,29 +16,20 @@ class user_authenticate extends AnonymousModule
|
|||
|
||||
public function __default()
|
||||
{
|
||||
try
|
||||
// Checks if the email supplied is valid
|
||||
if ($uid = $this->redis->get('user:email:' . trim($_POST['email'])))
|
||||
{
|
||||
$user = new User();
|
||||
// Grabs the password hash and auth token
|
||||
$user = $this->redis->hmget('user:' . $uid, array('password', 'auth'));
|
||||
|
||||
// Checks if the email supplied is valid
|
||||
if ($uid = $user->getMapping('email', $_POST['email']))
|
||||
// Checks if the password is valid
|
||||
if ($user['password'] == crypt($_POST['password'], $user['password']))
|
||||
{
|
||||
// Checks if the password is valid
|
||||
$password = $user->getPassword($uid);
|
||||
|
||||
if ($password == crypt($_POST['password'], $password))
|
||||
{
|
||||
$auth_token = $user->getAuth($uid);
|
||||
setcookie('__auth', base64_encode($uid . '|' . $auth_token), time() + Time::YEAR, '/');
|
||||
}
|
||||
setcookie('__auth', base64_encode($uid . '|' . $user['auth']), time() + Time::YEAR, '/');
|
||||
}
|
||||
|
||||
return array('status' => 'success', 'url' => '/');
|
||||
}
|
||||
catch (RedisException $e)
|
||||
{
|
||||
return array('error' => $e->getMessage());
|
||||
}
|
||||
|
||||
return array('error' => 'Invalid email address or password.');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue