laravel 5.4 中 ResetPasswords.php 中未定义路由 [password.reset]

2024-03-02

我在我的自定义应用程序中收到此错误:

InvalidArgumentException in UrlGenerator.php line 304: 
Route [password.reset] not defined.

我知道 laravel 提供了开箱即用的密码重置功能,但我想编写自己的类和路由。

这是我在 web.php 中的路线

// Password reset link request routes...
Route::get('password/email', 'Auth\PasswordController@getResetEmail');
Route::post('password/email', 'Auth\PasswordController@postResetEmail');

// Password reset routes...
Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
Route::post('password/reset', 'Auth\PasswordController@postReset');

这是我的密码控制器:

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller {



    use ResetsPasswords;

    /**
     * Create a new password controller instance.
     *
     * @param  \Illuminate\Contracts\Auth\Guard  $auth
     * @param  \Illuminate\Contracts\Auth\PasswordBroker  $passwords
     * @return void
     */
    public function __construct(Guard $auth, PasswordBroker $passwords)
    {
        $this->auth = $auth;
        $this->passwords = $passwords;
        $this->middleware('guest');
    }
}

这是我的 ResetPasswords.php 特征:

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

trait ResetsPasswords
{
    use RedirectsUsers;

    /**
     * Display the form to request a password reset link.
     *
     * @return \Illuminate\Http\Response
     */
    public function getResetEmail()
    {
        return view('public.auth.password');
    }

    /**
     * Send a reset link to the given user.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function postResetEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);

        $response = Password::sendResetLink($request->only('email'), function (Message $message) {
            $message->subject($this->getEmailSubject());
        });

        switch ($response) {
            case Password::RESET_LINK_SENT:
                return redirect()->back()->with('status', trans($response));

            case Password::INVALID_USER:
                return redirect()->back()->withErrors(['email' => trans($response)]);
        }
    }

    /**
     * Get the e-mail subject line to be used for the reset link email.
     *
     * @return string
     */
    protected function getEmailSubject()
    {
        return property_exists($this, 'subject') ? $this->subject : 'Your Password Reset Link';
    }

    /**
     * Display the password reset view for the given token.
     *
     * @param  string  $token
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getReset($token = null)
    {
        if (is_null($token)) {
            throw new NotFoundHttpException;
        }

        return view('public.auth.reset')->with('token', $token);
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function postReset(Request $request)
    {
        $this->validate($request, [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ]);

        $credentials = $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );

        $response = Password::reset($credentials, function ($user, $password) {
            $this->resetPassword($user, $password);
        });

        switch ($response) {
            case Password::PASSWORD_RESET:
                return redirect($this->redirectPath())->with('status', trans($response));

            default:
                return redirect()->back()
                            ->withInput($request->only('email'))
                            ->withErrors(['email' => trans($response)]);
        }
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $password
     * @return void
     */
    protected function resetPassword($user, $password)
    {
        $user->password = bcrypt($password);

        $user->save();

        Auth::login($user);
    }
}

问题是当我按下密码重置表单按钮时,它会导致该错误。

任何帮助,将不胜感激...


这些路线需要一个名称。

这里的代码..

// Password reset link request routes...
Route::get('password/email', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.email');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');

// Password reset routes...
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request');
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

laravel 5.4 中 ResetPasswords.php 中未定义路由 [password.reset] 的相关文章

  • 如何在 Laravel 5 中使用 Orchestral/Tenanti 构建具有多个数据库的多租户应用程序?

    我正在尝试使用 Laravel 5 构建和应用程序 它应该是使用多个数据库的多租户数据库架构 我的雇主出于安全目的要求这样做 我尝试手动管理主数据库迁移和租户迁移 但失败了 所以我决定借助 Laravel 特定包的帮助 这应该是我所需要的
  • CodeIgniter 项目给出 303/压缩错误

    尝试设置一个基于 CodeIgniter 的项目进行本地开发 LAMP 堆栈 并且一旦更新了所有配置文件 这意味着我成功地为 CodeIgniter 生成了有意义的引导错误 我在浏览器中收到此错误 Chrome Error 330 net
  • 从 PHP SoapServer 返回 PHP 数组

    我对 Soap 的 创建服务端 还比较陌生 所以提前对我正在思考的任何术语表示歉意 是否可以从使用 PHP 的 SoapServer 类设置的远程过程 Soap 服务返回 PHP 数组 我有一个 WSDL 通过盲目遵循教程构建 部分看起来像
  • PHP 不使用“json_decode()”转换 JSON

    我有一段非常简单的代码 pc1 POST post code1 pc2 POST post code2 url http maps google com maps nav q from pc1 20to pc2 url data file
  • 我应该存储密码的哈希值吗?

    用户系统和密码 我正在查看 MD5 内容 我想知道密码的正常 良好做法是什么 现在 我认为人们对密码进行超级加密并存储哈希值 如果是这样 密码检查如何工作 我只是让输入的密码再次经过加密过程 然后用存储的哈希值检查哈希值 对吗 这个问题可能
  • 用于解析差异的 PHP 类

    我正在编写一个 PHP 脚本 需要解释 Git 创建的 Diff 文件 如果我想解析 Diff 文件并基本上以完全不同的格式打印它 我应该如何进行 我遇到过Text DiffPEAR 库 但该库仅创建 Diff 本身 或者更确切地说 它只需
  • PHP 中的数组按值排序并维护索引关联

    我有一个数组 array array john gt 2 adam gt 3 ben gt 10 tim gt 1 我已经尝试了 PHP 的各种函数来实现这个数组结构 array array tim gt 1 john gt 2 adam
  • OpenSSL 真的需要 openssl.conf 的路径吗?

    我想在 PHP 5 x 中创建自签名证书 使用我自己的 替代 openssl 配置 该配置应该由我的 PHP 代码定义 PHP 脚本将在不同的环境 共享托管网络服务器 上运行 官方PHP手册 http php net manual en f
  • WSDL PHP 函数返回 null,而其他函数返回预期结果

    Summary 在这里 我将列出我解决此问题所采取的所有步骤 以供其他人参考 1 PHP 很愚蠢地 监听 函数的输入消息来定义它应该使用哪个函数 因此 为每个函数提供不同的输入消息 即使它使用相同的类型或元素 您可能认为这对您来说是一项艰巨
  • Laravel-5 如何使用 id 值和名称值从数据库填充选择框

    我想创建一个如下所示的选择框照亮 html https github com illuminate html
  • 使用 php 和 mysql 计算日期差(以小时为单位)

    我如何使用 php 和 mysql 找到以小时为单位的日期差异 Use TIMEDIFF http dev mysql com doc refman 5 1 en date and time functions html function
  • 如何在 的每四个循环项之后添加

    我想在循环中的每第四个数字项之后退出循环 我想创建一个二十人的名单 在每一个tr应该是4个人 So I want to break from the loop after every 4th number of loop My one tr
  • WooCommerce 从前端(而不是管理员)隐藏订单项元

    我有一些我不希望客户看到的订单项元详细信息 在帐户信息下的查看订单页面上 我找到了一个过滤器 可以从管理员 我仍然希望看到它 中删除这些数据 但找不到类似的过滤器来从前端 应该隐藏它 中删除它 这是将从后端管理中删除它的代码 对我来说毫无用
  • 通过 Amazon SQS 将压缩文本从 PHP 发送到 NodeJS

    我似乎一直坚持通过 Amazon SQS 将压缩消息从 PHP 发送到 NodeJS 在 PHP 方面我有 SQS gt sendMessage Array QueueUrl gt queueUrl MessageBody gt artic
  • Composer 自动加载器未加载 GuzzleHttp\ClientInterface

    我正在尝试使用Guzzle http guzzle readthedocs org en latest 但我得到以下内容致命错误 致命错误 找不到类 GuzzleHttp ClientInterface var www myapp vend
  • PHP - 调整 PNG 图像大小时出现内存错误

    我有一个脚本可以根据上传的图像创建缩略图 它对 jpg 工作正常 但给我一个错误 致命错误 允许的内存大小 67108864 字节已耗尽 尝试分配 26250000 字节 当我上传 png 图像时 脚本是 create thumbnail
  • 56 CONNECT 后收到来自代理的 HTTP 代码 403?

    使用 cUrl 从我的网页生成销售人员线索时 出现 56 在 CONNECT 后从代理接收到 HTTP 代码 403 错误 该网站的 SSL 证书已过期 UPDATED 我的代码如下 curl setopt curl CURLOPT URL
  • 使用 Laravel 和 Eloquent 从表中选择全部

    我正在使用 Laravel 4 设置我的第一个模型 以从名为的表中提取所有行posts 在标准 MySQL 中我会使用 SELECT FROM posts 如何在 Laravel 4 模型中实现这一目标 我的完整模型源代码如下
  • 当我尝试计算 mysqli 结果时,为什么会收到警告?

    下面的代码会导致此警告 警告 count 参数必须是数组或实现 Countable 的对象 为什么要这样做 如何防止出现警告 if isset GET edit sonum GET edit update true result mysql
  • 将 #RRGGBB 十六进制值转换为 #AARRGGBB

    414141 与 AARRGGBB 的值是什么 52b531 又如何 我如何使用 PHP 转换它 Regards 奔腾10 AA 是 Alpha 通道 直接转换是将 AA 设置为 FF 以使其完全不透明 414141 becomes FF4

随机推荐