Created
February 17, 2015 01:47
-
-
Save rfos/b5a705ada498b8c1f4a4 to your computer and use it in GitHub Desktop.
Validação Link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//UserController.php | |
public function validarSenha($id, $token) { | |
$this->autoRender = false; | |
if (empty($id) || empty($token)) | |
throw new NotFoundException; | |
if ($user = $this->User->passReset($id, $token)) { | |
$this->Auth->login($user['User']); | |
$this->redirect(array('controller' => 'perfil', 'action' => 'troca-senha' . '/' . $id)); | |
} else { | |
$this->Session->setFlash('O link informado já foi utilizado ou está incorreto', 'flash/error'); | |
$this->redirect(array('controller' => 'inicio', 'action' => 'login')); | |
} | |
} | |
// Model User.php | |
//Ativação do usuário | |
public function passReset($id, $token) | |
{ | |
//Checa se existe o usuário informado com o respectivo código | |
if ($this->hasAny(array("{$this->alias}.id" => $id, "{$this->alias}.token" => $token))) { | |
return $this->read(array('id', 'nome', 'email', 'token', 'group_id'), $id); | |
} | |
// Se nao encontra valores, retorna false para Controller validaEmail | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment