Laravel:我如何验证reset_password表令牌和请求令牌

时间:2018-04-26 10:17:21

标签: laravel laravel-5.5

我只是在我的应用中重置了密码。所以,如果user可用email,phone user,我token reset_password检查token可用性{1}}作为回应。但是当我检查reset_password表令牌和response令牌时,两者都不同。如何检查和验证请求令牌和存储的令牌。

注意:在邮递员中测试

$api->post('confirmuser', 'App\\Api\\V1\\Controllers\\Auth\\ForgotPasswordController@confirmUser');

以下是我的controller代码emailphone i验证,如果用户数据在user表插入令牌和电子邮件reset_password表上可用并返回以回应

public function confirmUser(Request $request)
{
    $validator = Validator::make($request->all(), User::confirmUserRules());
    $user  = User::leftjoin('user_details','users.id', '=', 'user_details.user_id')
                ->where('user_details.phone', '=', $request->post('phone'))
                ->where('users.email', '=', $request->post('email'))
                ->first();

    if(!$user) {
        return response()->json([
            'message'       => "Email and phone number not match",
            'status_code'   => 404,
        ]);
    }
        // Here entry in reset_password table
        $passwordBroker = $this->getPasswordBroker();
        $tokens = $passwordBroker->getRepository();
        $token = $tokens->create($user);
        return response()->json([
            'message'       => "Your account is eligible for change password.!!",
            'token'         => $token,
            'status_code'   => 200
        ]);
}

这是我的回复:

{
"message": "Your account is eligible for change password.!!",
"token": "49f0b98b0a2361bb094df9191fc87ec698463da9b9cad5d6d3b4284ae69368e4",
"status_code": 200
}

Reset_password表标记: enter image description here

现在我要验证reset_password令牌和user获取令牌。我怎么验证?两者都不同。

0 个答案:

没有答案