如何覆盖 Laravel 5.6 的默认忘记密码机制?

How to override default forgot password mechanism of Laravel 5.6?

如果用户 table 的状态字段设置为 1,我想登录用户,否则不登录。所以这个问题在我问的这个问题中得到了解决。

但是现在我遇到了另一个问题。当状态为 0(未激活) 的用户单击 默认忘记密码 link 登录页面 并输入他的电子邮件地址,然后单击重置 link 并填写新密码,即使他的状态为 0(未激活),他也会自动登录。

如果用户状态为 0,我该如何防止忘记密码机制?

转到 ForgotPasswordController 并粘贴它。存在相同的机制 。所以我没有解释清楚。

public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);
        $userStatus=User::where('email','=',$request->email)->limit(1)->get();
            if (isset($userStatus)) {
                if ($userStatus[0]->role==0) {
                return redirect()->back()->with(['massage'=>'Please activate account first']);
            }
        }


        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        return $response == Password::RESET_LINK_SENT
                    ? $this->sendResetLinkResponse($response)
                    : $this->sendResetLinkFailedResponse($request, $response);
    }