Skip to content

Call to undefined method App\Exceptions\Handler::unauthenticated() in laravel 5.4 #18877

Closed
@alfonsobries

Description

@alfonsobries
  • Laravel Version: 5.4
  • PHP Version: 7.1.3
  • Database Driver & Version: Mysql (homestead)

Description:

I just update my app from 5.3 to 5.4

I found that when my user is not logged and i go to a route that needs authentication my app trows the exception: "Call to undefined method App\Exceptions\Handler::unauthenticated()", i can fix the problem with some validation but i think that exist an error in the framework:

If you see the functions(unauthenticated()) seems that dissapear in the 5.4 but its still referenced in the Exceptions/Handler.php file:

vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php
line 114

} elseif ($e instanceof AuthenticationException) {
// You call the function unauthenticated but isn't exists
            return $this->unauthenticated($request, $e);

if you see the same file in the 5.3 version this function actually exists Illuminate/Foundation/Exceptions/Handler.php line 186 (version 5.3):

    protected function unauthenticated($request, AuthenticationException $e)
    {
        if ($request->ajax() || $request->wantsJson()) {
            return response('Unauthorized.', 401);
        } else {
            return redirect()->guest('login');
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions