我正在训练在Laravel 10项目中判断密码验证,但函数"check"返回假,而且,我可以使用相同的密码登录.我不知道为什么返回假.
谢谢.
public function recharge_by_client(Request $request){
$telf = $request->telf;
$password = $request->password;
$credit = $request->credit;
try {
$client = Client::where('telf', $telf)->first();
//if verification data is false, returning 0.
if ($client && Hash::check($password, $client->password)) {
\Log::info('Entramos a update');
HomeHelper::recharge_money($client->id, $credit);
}else{
\Log::info('NO entramos a update');
return ['credit_updated' => 0];
}
} catch (\Exception $e) {
\Log::info($e->getMessage());
//A exception has ocurre, returning 0.
return ['credit_updated' => 0];
}
//Returning current credit.
return ['credit_updated' => Client::find($client->id)->credit];
}