Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid signaure #98

Closed
piotr-sikora-v opened this issue Dec 30, 2021 · 6 comments
Closed

Invalid signaure #98

piotr-sikora-v opened this issue Dec 30, 2021 · 6 comments

Comments

@piotr-sikora-v
Copy link

I do everythong one by one from tutorial.
I can register user, login etc.
but link in email i recive is always with exeption "The link to verify your email is invalid. Please request a new link."

I running clear php-apache on docker
timezone is OK
URL is ok (is in http without ssl)
maybe is not good couse i have local addresses for docker ending with ".docker" ?
my example url is: http://symofny5.docker/verify/email?expires=1640891770&id=8&signature=%2B%2BqkHGkLMIcXl1qVly%2BhdM9FeXtTLrhTYdQHSJppSZk%3D&token=GEEDqW1Wk2FUfTsy3T2S10%2BzvnVxuXBNo%2B%2BEU2X5NXk%3D

I checked, and ID is ok, in function "verifyUserEmail" it find good user.

I use symfony 5.4.2 php 7.4

Thanks in advanced!

@online-werbung
Copy link

Same here, but with Symfony 6 and php 8.1 on localhost without specific domain name.
Has anybody had this issue and solved it?

@jrushlow
Copy link
Collaborator

jrushlow commented Oct 4, 2022

This may be caused by a long standing bug that I just uncovered in MakerBundle where the {{ signedUrl }} in email.html.twig should have used the raw filter. e.g. {{ signedUrl|raw }}

This has been fixed in https://github.com/symfony/maker-bundle/releases/tag/v1.47.0
For existing templates, add the |raw filter to the template as shown above. Checkout symfony/maker-bundle#1217 for additional details.

@jrushlow jrushlow closed this as completed Oct 4, 2022
@tpinne
Copy link

tpinne commented Oct 8, 2022

I have the same problem, still with the added raw filter. But strangely only on my deployed application and not locally. Adding the filter made no difference, still works locally and not deployed.

I use the bundle in an api-platform environment, which runs locally via docker-composer und is deployed via kubernetes.

I dispatch a message manually which triggers the following handler

<?php

namespace App\MessageHandler;

use App\Message\VerifyEmailAddressMessage;
use App\Repository\UserRepository;
use App\Security\EmailVerifier;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

final class VerifyEmailAddressHandler implements MessageHandlerInterface {

    public function __construct(
        private EmailVerifier $emailVerifier,
        private UserRepository $userRepository,
        private MailerInterface $mailer
    ) {
    }

    public function __invoke(VerifyEmailAddressMessage $verifyEmailAddressMessage) {
        $user = $this -> userRepository -> find($verifyEmailAddressMessage -> getUserId());

        if ($user) {
            $this -> emailVerifier -> sendEmailConfirmation('app_register_verify', $user,
                (new TemplatedEmail())
                    -> to($user -> getEmail())
                    -> subject('My subject')
                    -> htmlTemplate('email/auth/verify_email/email.html.twig')
            );
        } else {
// .....
        }
    }
}

and with the content of the following email template:

{% extends 'email/base.html.twig' %}

{% block content %}

    <p>Hi,</p>

    <p>Bla blabla.</p>

    <a href="{{ signedUrl | raw }}">Verify email address</a>
{% endblock %}

@rsteuber
Copy link

I have the same problem, still with the added raw filter. But strangely only on my deployed application and not locally. Adding the filter made no difference, still works locally and not deployed.

I use the bundle in an api-platform environment, which runs locally via docker-composer und is deployed via kubernetes.

I dispatch a message manually which triggers the following handler

<?php

namespace App\MessageHandler;

use App\Message\VerifyEmailAddressMessage;
use App\Repository\UserRepository;
use App\Security\EmailVerifier;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

final class VerifyEmailAddressHandler implements MessageHandlerInterface {

    public function __construct(
        private EmailVerifier $emailVerifier,
        private UserRepository $userRepository,
        private MailerInterface $mailer
    ) {
    }

    public function __invoke(VerifyEmailAddressMessage $verifyEmailAddressMessage) {
        $user = $this -> userRepository -> find($verifyEmailAddressMessage -> getUserId());

        if ($user) {
            $this -> emailVerifier -> sendEmailConfirmation('app_register_verify', $user,
                (new TemplatedEmail())
                    -> to($user -> getEmail())
                    -> subject('My subject')
                    -> htmlTemplate('email/auth/verify_email/email.html.twig')
            );
        } else {
// .....
        }
    }
}

and with the content of the following email template:

{% extends 'email/base.html.twig' %}

{% block content %}

    <p>Hi,</p>

    <p>Bla blabla.</p>

    <a href="{{ signedUrl | raw }}">Verify email address</a>
{% endblock %}

Did you already have a solution fo this. I have the same problem en the helper still comes with an exception that link is not valid.

Cheers!

@fschasse
Copy link

fschasse commented Nov 25, 2023

@rsteuber @tpinne Hey, exactly the same problem for me. Work on dev (local) but not in prod (online). Have you find a solution ?

@rsteuber
Copy link

I have the same problem, still with the added raw filter. But strangely only on my deployed application and not locally. Adding the filter made no difference, still works locally and not deployed.
I use the bundle in an api-platform environment, which runs locally via docker-composer und is deployed via kubernetes.
I dispatch a message manually which triggers the following handler

<?php

namespace App\MessageHandler;

use App\Message\VerifyEmailAddressMessage;
use App\Repository\UserRepository;
use App\Security\EmailVerifier;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

final class VerifyEmailAddressHandler implements MessageHandlerInterface {

    public function __construct(
        private EmailVerifier $emailVerifier,
        private UserRepository $userRepository,
        private MailerInterface $mailer
    ) {
    }

    public function __invoke(VerifyEmailAddressMessage $verifyEmailAddressMessage) {
        $user = $this -> userRepository -> find($verifyEmailAddressMessage -> getUserId());

        if ($user) {
            $this -> emailVerifier -> sendEmailConfirmation('app_register_verify', $user,
                (new TemplatedEmail())
                    -> to($user -> getEmail())
                    -> subject('My subject')
                    -> htmlTemplate('email/auth/verify_email/email.html.twig')
            );
        } else {
// .....
        }
    }
}

and with the content of the following email template:

{% extends 'email/base.html.twig' %}

{% block content %}

    <p>Hi,</p>

    <p>Bla blabla.</p>

    <a href="{{ signedUrl | raw }}">Verify email address</a>
{% endblock %}

Did you already have a solution fo this. I have the same problem en the helper still comes with an exception that link is not valid.

Cheers!

nope :(, but were working on it. If we got a solution... I let you know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants