Skip to content

Instantly share code, notes, and snippets.

@kolomiec-valeriy
Created August 30, 2019 11:39
Show Gist options
  • Save kolomiec-valeriy/f5114dec72cae9efa215736f5ed85f60 to your computer and use it in GitHub Desktop.
Save kolomiec-valeriy/f5114dec72cae9efa215736f5ed85f60 to your computer and use it in GitHub Desktop.
<?php
namespace App\Controller;
use App\Entity\ApiUser;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class ResetUserPasswordController extends Controller
{
/**
* @Route("/reset-pass")
* @param UserPasswordEncoderInterface $userPasswordEncoder
*
* @return Response
*/
public function resetPassword(UserPasswordEncoderInterface $userPasswordEncoder)
{
$em = $this->getDoctrine()->getManager();
/** @var ApiUser $user */
// $user = $em->getRepository(ApiUser::class)->findOneBy(["email" => "sarie@me.com"]);
$user = $em->getRepository(ApiUser::class)->find(990);
$pass = $userPasswordEncoder->encodePassword($user, "bBCTjRos");
$user->setPassword($pass);
$em->flush();
return new Response($pass);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment