3 weeks ago

$request->user = Unauthorized

Posted 3 weeks ago by GrahamMorbyDev

I have a laravel/Vue application which Im trying to set up cashier on.

When I got to set up a payment intent I get an Unauthorized return


My login controller looks like so

public function login(Request $request)
        $credentials = $request->only('email', 'password');
        if ($token = $this->guard()->attempt($credentials)) {
           return response()->json([
                'status' => 'success',
                'data' => $token
            ], 200);
        return response()->json(['error' => 'login_error'], 401);

So I'm guessing I'm not setting something correctly here, and laravel is not aware of who is logged in.

I have added the middleware to my endpoint to set payment intent

Route::group(['prefix' => 'payment'], function() {
    Route::get('setup-intent', '[email protected]')->middleware('auth:api');

Any help would be greatly welcomed

Please sign in or create an account to participate in this conversation.