Exemplo n.º 1
0
 public static function recoverPassword($id, $newPassword1, $newPassword2, $generatedString)
 {
     if (strcmp($newPassword1, $newPassword2) !== 0) {
         throw new Exception("There was a mismatch with the new passwords");
     }
     User::validatePassword($newPassword1);
     if (!UserFetcher::generatedStringExists($id, $generatedString)) {
         throw new Exception("Could not verify generated string exists. Please make sure url sent was not modified.");
     }
     if (User::isGeneratedStringExpired($id, $generatedString)) {
         throw new Exception("Sorry that link has expired. Please <a href='" . App::getDomainName() . "/login/confirm-password'\n\t\t\t\t\t\t\ttarget='_self'>request</a> a new one");
     }
     UserFetcher::updatePassword($id, $newPassword1);
 }