3
I’m developing an application, and I’m having doubts in the password recovery part.
I have a method that the user inserts the email that is registered in the application when they forget the password. Ex:
public function esqueciSenha($email)
{
self::enviaEmail($email);
...
}
That function mail, generates a password recovery token, and will send a URL to the user via email. Ex:
http://aplicacao.com/alterarSenhaPorToken?token=6d352bcc2811a85820d5252df9bb9086&id=1
In the generated URL, you will have a form for the user to enter the new password. I thought of making AJAX take the password change token, the user id (passed in the url) and the new password, and send to the change method NhaPorToken (via POST), which receives $id, $token and $newNew, and will validate the token and id, and thus change the password of the user.Ex:
public function alterarSenhaPorToken($id, $token, $novaSenha){
// validação do token
...
self::trocarSenha($id, $novaSenha);
...
}
My doubts:
Are there problems in passing the user token and id through the URL? On security issues? If there are problems, what would be the safest way to do this?
In the database register the token with the user id, according to this id, ai Voce does a search when generating the new password, so Voce can by token identify who is the user requesting the exchange... ai do o update\
– Sr. André Baill
Thank you @Andrébaill, I will do what you suggest and test!
– mauricio caserta