Token Mismatch Exception on Login (Laravel)

后端 未结 6 2076
说谎
说谎 2021-01-14 22:14

I followed this tutorial on creating a registration and login page using Laravel.

Everything works smoothly, the only issue is that I am unable to Login. If I provid

6条回答
  •  难免孤独
    2021-01-14 22:55

    I added the following code to app\Exceptions\Handler.php to help clarify the error for the end-user, in addition to setting session to expire on close, as mentioned in this thread.

        protected function prepareException(Exception $exception)
        {
            if ($exception instanceof TokenMismatchException) {
                return new HttpException(
                    419,
                    "{$exception->getMessage()}. Please clear your browser cookies and try again.",
                    $exception
                );
            }
    
            return parent::prepareException($exception);
        }
    

提交回复
热议问题