Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Route [login] not defined" #129

Open
Aontaigh opened this issue May 13, 2020 · 0 comments
Open

Error "Route [login] not defined" #129

Aontaigh opened this issue May 13, 2020 · 0 comments

Comments

@Aontaigh
Copy link

Aontaigh commented May 13, 2020

Laravel Version: 5.8
Multiauth Version: 5

I get the error as mentioned above when attempting to hit a protected route when not logged in and authenticated.

For example, imagine one is not logged in and attempts to hit the route customers:

Route::group(['prefix' => 'v1/osf', 'middleware' => ['multiauth:customer,api']], function () {
    Route::get('customers', 'OpenShopFront\Customers\CustomerControllerr@index');
    Route::get('customer/{id}', 'OpenShopFront\Customers\CustomerControllerr@show');
});

This will cause a 500 error stating "Error "Route [login] not defined".

I know when using passport you can use the Authenticate.php middleware and do something along the lines of:

<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware {
    protected function redirectTo($request) {
        abort(response()->json([
            'status' => 'error',
            'message_short' => 'Not Authenticated - Please Login',
            'message_long' => null,
            'validation_error' => null
        ], 401));
    }
}

How would something such as the above be achieved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant