breeze 验证方法在从我的 vue 调用时不起作用

问题描述 投票:0回答:0

AuthenticatedSessionController.php

public function store($request): 
{
    dd($request->all());

    $request->authenticate();
    $request->session()->regenerate();

    // No errors occurred, return JSON response
    return response()->json(['message' => 'Verification successful']);
}

登录请求.php

public function authenticate(): void
{
    $this->ensureIsNotRateLimited();
    $user = User::where('phone', $this->input('phone'))->first();
    if (! $user) {
        RateLimiter::hit($this->throttleKey());
        throw ValidationException::withMessages([
            'phone' => trans('auth.failed'),
        ]);
    }
    if (Auth::attempt(['phone' => $this->input('phone')])) {
        RateLimiter::clear($this->throttleKey());
    } else {
        RateLimiter::hit($this->throttleKey());
        throw ValidationException::withMessages([
            'phone' => trans('auth.failed'),
        ]);
    }
} 

当我从默认的微风组件发送请求时,它可以工作,但是我使用我的 vue 组件,它给了我 500 错误

php laravel vue.js authentication breeze
© www.soinside.com 2019 - 2024. All rights reserved.