如何重写Laravel 5.6的默认忘记密码机制? [英] How to override default forgot password mechanism of Laravel 5.6?

查看:99
本文介绍了如何重写Laravel 5.6的默认忘记密码机制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户的状态表的状态字段设置为1,我想登录该用户.因此,这个问题在我提出的这个问题中得到了解决.

I wanted to login the user if his status field of users table was set to 1 otherwise not. So this problem was solved in this question which I had asked.

如何覆盖Laravel 5.6的默认登录机制?

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

But now I am having another problem. When a user whose status is 0(not active) clicks the default forgot password link in login page and enters his email address and then clicks the reset link and fills the new password, he automatically gets logged in even though his status is 0(not active).

那么,如果用户的状态为0,如何防止忘记密码机制?

So how can I prevent the forgot password mechanism if user's status is 0 ?

推荐答案

转到ForgotPasswordController并将其粘贴. 此处存在相同的机制.因此,我的解释不正确.

Go to ForgotPasswordController and paste it. the same mechanism exist here . therefor I am not explaining properly.

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);
    }

这篇关于如何重写Laravel 5.6的默认忘记密码机制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆