fixed custmer login
This commit is contained in:
parent
adf9f84684
commit
35677a7dd2
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Illuminate\Foundation\Exceptions\RegisterErrorViewPaths;
|
use Illuminate\Foundation\Exceptions\RegisterErrorViewPaths;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
|
@ -41,6 +42,27 @@ class Handler extends ExceptionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the given exception to an array.
|
||||||
|
*
|
||||||
|
* @param \Throwable $e
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function convertExceptionToArray(Throwable $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
return config('app.debug') ? [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'exception' => get_class($e),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine(),
|
||||||
|
'trace' => collect($e->getTrace())->map(fn ($trace) => Arr::except($trace, ['args']))->all(),
|
||||||
|
] : [
|
||||||
|
'message' => $this->isHttpException($e) ? $e->getMessage() : 'Server Error',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义错误信息页面, 前台与后台不同, 需要分开定义
|
* 自定义错误信息页面, 前台与后台不同, 需要分开定义
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,13 @@
|
||||||
namespace Beike\Shop\Http\Controllers\Account;
|
namespace Beike\Shop\Http\Controllers\Account;
|
||||||
|
|
||||||
use Beike\Models\Customer;
|
use Beike\Models\Customer;
|
||||||
use Beike\Shop\Http\Controllers\Controller;
|
|
||||||
use Beike\Shop\Http\Requests\LoginRequest;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Beike\Shop\Http\Requests\LoginRequest;
|
||||||
|
use Beike\Shop\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Validation\UnauthorizedException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -29,13 +33,13 @@ class LoginController extends Controller
|
||||||
public function store(LoginRequest $request)
|
public function store(LoginRequest $request)
|
||||||
{
|
{
|
||||||
if (!auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) {
|
if (!auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) {
|
||||||
throw new \Exception(trans('shop/login.email_or_password_error'));
|
throw new NotAcceptableHttpException(trans('shop/login.email_or_password_error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer = current_customer();
|
$customer = current_customer();
|
||||||
if ($customer && $customer->status != 1) {
|
if ($customer && $customer->status != 1) {
|
||||||
Auth::guard(Customer::AUTH_GUARD)->logout();
|
Auth::guard(Customer::AUTH_GUARD)->logout();
|
||||||
throw new \Exception(trans('shop/login.customer_inactive'));
|
throw new NotFoundHttpException(trans('shop/login.customer_inactive'));
|
||||||
}
|
}
|
||||||
return json_success(trans('shop/login.login_successfully'));
|
return json_success(trans('shop/login.login_successfully'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue