I just reset password in my app.So i check user
availability with email,phone
if user
is available store token
in reset_password
table and return token
in response. But when i check reset_password
table token and response
token both are different.? How can i check and validate request token and stored token.
note: Tested in postman
$api->post('confirmuser', 'App\\Api\\V1\\Controllers\\Auth\\ForgotPasswordController@confirmUser');
Here is my controller
code with email
and phone
i validate, if user data is available on user
table insert token and email to reset_password
table and return in response to
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
]);
}
And here is my return response :
{
"message": "Your account is eligible for change password.!!",
"token": "49f0b98b0a2361bb094df9191fc87ec698463da9b9cad5d6d3b4284ae69368e4",
"status_code": 200
}
And Reset_password
table token :
now i want to validate reset_password
token and user
get token. how can i validate ? As both are different.