Przebrnąłem przez rejestrację użytkownika, teraz czas na potwierdzenie adresu.
Wysyłam do usera email z linkiem do potwierdzenia adresu.
User klika na link.
Funkcja odpowiadająca za sprawdzenie czy user o podanym is_activate jest w bazie.
/** * @Route("/activate/{isActivate}", name="app_activate") */ public function activate( string $isActivate ) { /* if($this->getUser()) { return $this->redirectToRoute('index'); } */ $em = $this->getDoctrine()->getManager(); $user = $em->getRepository(User::class) ->findOneBy( [ 'is_activate' => $isActivate ] ); }
Po kliknięciu w link otrzymuję taki oto komunikat.
The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null. Did you forget to add a return statement somewhere in your controller?
Klasa User
class User implements UserInterface { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=180, unique=true) */ private $username; /** * @ORM\Column(type="json") */ private $roles = []; /** * @var string The hashed password * @ORM\Column(type="string") */ private $password; /** * */ private $plainPassword; /** * @ORM\Column(type="string", length=255, unique=true) */ private $email; /** * @ORM\Column(type="integer") */ private $status = 0; /** * @ORM\Column(type="string") */ private $is_activate; /** * @ORM\Column(type="boolean") */ private $isVerified = false; public function getId(): int { return (integer) $this->id; } /** * A visual identifier that represents this user. * * @see UserInterface */ public function getUsername(): string { return (string) $this->username; } public function setUsername(string $username): self { $this->username = $username; return $this; } public function getStatus(): int { return (integer) $this->status; } public function setStatus(int $status): self { $this->status = $status; return $this; } /** * @see UserInterface */ { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; } { $this->roles = $roles; return $this; } /** * @see UserInterface */ public function getPassword(): string { return (string) $this->password; } public function setPassword(string $password): self { $this->password = $password; return $this; } /** * @see UserInterface */ public function getIsActivate(): string { return (string) $this->is_activate; } public function setIsActivate(string $is_activate): self { $this->is_activate = $is_activate; return $this; } /** * @see UserInterface */ public function getSalt() { // not needed when using the "bcrypt" algorithm in security.yaml } /** * @see UserInterface */ public function eraseCredentials() { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): self { $this->email = $email; return $this; } public function isVerified(): bool { return $this->isVerified; } public function setIsVerified(bool $isVerified): self { $this->isVerified = $isVerified; return $this; } public function getPlainPassword() { return $this->plainPassword; } public function setPlainPassword($password) { $this->plainPassword = $password; } }
Jak sprawdzić, czy dany user istnieje?
EDIT:
System działa, na samej górze system pokazuje mi email usera, ale oczekiwał zwrotu albo toRoute albo załadowania szablonu twiga.
Można zamknąć temat.