【问题标题】:How to make custom forgot controller?如何制作自定义忘记控制器?
【发布时间】:2023-03-25 04:24:01
【问题描述】:

在 laravel 中,有 auth::routes,但我不想使用它,而是想制作自己的忘记密码控制器。谁能告诉我该怎么做?

【问题讨论】:

    标签: laravel authentication model-view-controller forgot-password


    【解决方案1】:

    auth::routes() 只是一个包装器,你可以在vendor/laravel/framework/src/Illuminate/Routing/Router.php 中找到方法routes() 并查看该方法添加的所有路由。所以基本上只需删除 auth::route() 并使用您自己的控制器添加路由。

    这是其中的一些:

    $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
    $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    $this->post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
    

    路线可能会因您的 Laravel 版本而异。

    【讨论】:

    • 当我删除 auth::routes 并发送忘记密码的重置链接时,它显示发送重置链接表单而不是更改密码表单。我已经添加了这些路线
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-31
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多