cms icon indicating copy to clipboard operation
cms copied to clipboard

Route [password.reset] not defined when storing users in database.

Open jeremydouglas opened this issue 4 years ago • 16 comments

I'm getting this when submitting the forgot password form:

Route [password.reset] not defined.

I tested on a fresh install. At first the password reset worked. Then after moving users to the database, I replicated the error.

Environment

Statamic version: 3.0.0.-beta-40

PHP version: 7.4

Install method (choose one):

  • Fresh install from statamic/statamic

jeremydouglas avatar Jul 26 '20 03:07 jeremydouglas

Are password resets having an issue with users in DB still?

twd3 avatar Sep 09 '20 17:09 twd3

@twd3 you'll have to add your own routes to web.php.

I started with:

Auth::routes();

But, then customized as I needed.

jeremydouglas avatar Sep 09 '20 18:09 jeremydouglas

You'll need to elaborate on what you're doing here.

Why are you adding Auth::routes()? What else are you doing? When exactly are you getting the error? What did you click on? On which URL?

jasonvarga avatar Sep 16 '20 16:09 jasonvarga

@jasonvarga,

It's been a while now, but this was my experience:

  1. Follow the Statamic docs to move users to a database
  2. Complete the forgot password form. I recall using the /cp/auth/password/reset form.
  3. Error is returned: Route [password.reset] not defined.

A lot of this is explained in PR 2417.

jeremydouglas avatar Sep 16 '20 16:09 jeremydouglas

This is recreatable. Thanks!

jasonvarga avatar Sep 17 '20 00:09 jasonvarga

A workaround for this is to add the following to your User model (probably app/User.php)

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new \Statamic\Notifications\PasswordReset($token));
    }

jasonvarga avatar Sep 17 '20 02:09 jasonvarga

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

github-actions[bot] avatar Jan 08 '21 02:01 github-actions[bot]

Just ran into this. Please keep open.

johncarter- avatar Feb 10 '21 13:02 johncarter-

@johncarter- did you give the workaround posted above a try?

jeremydouglas avatar Feb 10 '21 13:02 jeremydouglas

Yeah I did and can confirm it works. I thought it would be good to open it back up if people are stilling running into it though.

johncarter- avatar Feb 10 '21 13:02 johncarter-

Awesome, I agree it should either get built in or mentioned on the knowledge base article

jeremydouglas avatar Feb 10 '21 13:02 jeremydouglas

Just ran into this issue as well. The workaround above still works as some Laravel 8 and Statamic 3.0.46

An extra paragraph or two on the article @jeremydouglas mentioned would probably be a good idea. I'm heads down in a project right now but I'll try to come back if I have time in a week or two.

daronspence avatar Mar 07 '21 04:03 daronspence

I have also run into this using Laravel 8 and Statamic 3.2.10

The workaround https://github.com/statamic/cms/issues/2133#issuecomment-693770781 works, however it seems to generate password reset links only with http even if the form was submitted via https which ends up in a session mismatch. Looking further into that.

[edit] the https issue seems to be due to using ngrok locally for some oauth testing and the symfony request root() scheme determination. An annoyance, but not an issue for production.

beck24 avatar Oct 01 '21 19:10 beck24

@daronspence @beck24 give this an issue a 👍 so the core team can place it properly in the priority list.

edalzell avatar Oct 22 '21 22:10 edalzell

A workaround for this is to add the following to your User model (probably app/User.php)

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new \Statamic\Notifications\PasswordReset($token));
    }

Jason, should this go in the statamic/statamic repo so that folks at least have a working version?

edalzell avatar Oct 22 '21 22:10 edalzell

I ran into the same initial issue described by @jeremydouglas on a fresh install and following the steps to move users from file to DB.

Adding sendPasswordResetNotification method into User model seems to work fine.

Would be nice if this is added to the Storing Users in a Database.

gabrieldasilva avatar Sep 05 '22 13:09 gabrieldasilva

It's crazy that after 2 years that this hasn't been added to the docs yet. I understand that if it's too complicated to fix in the core, but it creates a hugely painful developer experience when you all of a sudden have half of the CMS authentication functionality break when you move to eloquent-based users (which is required quite often).

Are the docs open source? If so, can someone link me to them and I'll open a PR

Humni avatar Oct 05 '22 19:10 Humni

Of course, go to the page you think it should be on and click this: CleanShot 2022-10-05 at 12 20 31@2x

edalzell avatar Oct 05 '22 19:10 edalzell

@edalzell Thanks, I clearly didn't scroll down far enough!

https://github.com/statamic/docs/pull/926

Humni avatar Oct 05 '22 20:10 Humni

I'm closing this now since the workaround has since been added to the documentation.

duncanmcclean avatar Nov 03 '23 15:11 duncanmcclean

        request()->validate([
            'email' => 'required|email'
        ]);

        $status = Password::sendResetLink(
            request()->only('email')
        );

        return $status === Password::RESET_LINK_SENT
                    ? back()->with(['status' => __($status)])
                    : back()->withErrors(['email' => __($status)]);
                    

I have multi roler based authentication so i need to override the default route password.reset based on user type. how i fix it

Sagar724254 avatar May 27 '24 05:05 Sagar724254

This issue has been closed for six months.

Please open a discussion if you're looking for help in customizing Statamic.

duncanmcclean avatar May 27 '24 09:05 duncanmcclean