E
E
EVOSandru62020-02-22 05:05:23
Laravel
EVOSandru6, 2020-02-22 05:05:23

What is the correct way in Laravel to recover a password through a phone number?

Good afternoon,

I want to provide the ability to recover a password not only through emai, as out of the box. but also through a phone number.

ForgotPasswordController has an entry:

$response = $this->broker()->sendResetLink(
            $request->only('email')
        );

and
public function broker()
    {
        return Password::broker();
    }

It is not entirely clear how this broker can be configured or replaced, a search in the file system did not give a result.

1) I would like to introduce some mode field, based on which I could change the Request request validation in the controller.
It's not a problem.
2) If I replace
$response = $this->broker()->sendResetLink(
            $request->only('email')
        );

on the
$response = $this->broker()->sendResetLink(
            $request->only('phone')
        );

then sending by SMS, respectively, will not happen. Is it possible to somehow configure the behavior of notifications at the broker level?

3) Also in the User class:
public function sendPasswordResetNotification($token)
    {
        $this->notify(new ResetPasswordNotification($token));
    }

Is it possible to somehow receive not only the $token parameter , but some additional $mode as input to the method , so that I can determine whether to send me SMS or Email?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2020-02-22
@EVOSandru6

2) How can I reset a user's password in Laravel if they don't have an email address?
3) Your broker can call any method with any parameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question