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

API returns 200 {'error' => 'Unauthorized'} #265

Open
hovocomunicativo opened this issue Dec 1, 2020 · 0 comments
Open

API returns 200 {'error' => 'Unauthorized'} #265

hovocomunicativo opened this issue Dec 1, 2020 · 0 comments

Comments

@hovocomunicativo
Copy link

Hello,
i've developed a mobile application making use of the laravue backend and API, but it happens that when I log-in in the app and make any other requests with the retrieved token, the api returns ['error' => 'Unauthorized'] with status 200.
i'm not sure of what is happening and what I'm missing here but the error is thrown from middleware/authenticate.php:

public function handle($request, Closure $next, ...$guards)
    {
        if ($this->authenticate($request, $guards) === 'authentication_error') {
            return response()->json(['error' => 'Unauthorized']);
        }

        return $next($request);
    }

    protected function authenticate($request, array $guards)
    {
        if (empty($guards)) {
            $guards = [null];
        }

        foreach ($guards as $guard) {
            if ($this->auth->guard($guard)->check()) {
                return $this->auth->shouldUse($guard);
            }
        }

        return 'authentication_error';
    }

After the login at the mobile app, all requests from the normal laravue web app or even from postman are responded with this same error.
Regards

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

0 participants