rvbrindle's avatar

send password reset link to a secondary email address as well as primary

Hi, i am trying to implement a forgot password request that emails the primary email ( as it currently does ) as well as the secondary email (if that is present)

I have tried sending the secondary_email ( this->broker()->sendResetLink ) to the broker as an array containing both email addresses but it only seems to send to the primary_email still.

Any help would be much appreciated

0 likes
2 replies
SilenceBringer's avatar

@rvbrindle you can dive into the code to understand why it doesn't work

Illuminate\Auth\Passwords\PasswordBroker

first of all, it returns the user by credentials.

$user = $this->getUser($credentials);

Only the first one user (you can find it if you dive deeper). So, multiple emails wil not works

next you can see

		if ($this->tokens->recentlyCreatedToken($user)) {
            return static::RESET_THROTTLED;
        }

so, if you'll try to call this methodd twice for 2 different emails - you'll get an error for the second time.

And - anyway email will be sent to the primary email, because in Illuminate\Auth\Passwords\CanResetPassword trait you can see

    public function getEmailForPasswordReset()
    {
        return $this->email;
    };

so, I think you can't do it with the existing functionallity - you need to implement it manually

2 likes
rvbrindle's avatar

ah thank you very much for your detailed response!

Please or to participate in this conversation.