0

我正在编写更改密码的代码。我的代码如下:

public function changePassword(ChangePasswordRequest $request)
{

     $credentials = ['email'=>Auth::user()->email, 'password'=>$request['old_password']];

    if (Auth::validate($credentials))
    {
        password change code;
    }
    else
    {
        What should be there?
    }
}

在不使用 ajax 的情况下,我们可以返回重定向以查看错误。如果旧密码错误,使用ajax时在else部分发送代码的错误应该是什么?我们也可以匹配 ChangePasswordRequest.php 中的旧密码吗?

4

1 回答 1

0
return response()->json(['old_password'=> ["Your old password is not correct."] ], 403);
于 2015-04-01T16:00:12.150 回答