Created
August 30, 2019 11:39
-
-
Save kolomiec-valeriy/f5114dec72cae9efa215736f5ed85f60 to your computer and use it in GitHub Desktop.
This file contains 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
<?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