dimanche 3 janvier 2021

Laravel auth doesn't work but all routes are properly created

I created routes and controllers for login and register, but when I try to go to either GET login or POST login, the pages don't show up, and no errors are logged in php_error.log (strange). I did make:auth and the routes and controllers get created, but I cannot get anything useful neither from GET /login or from POST /login requests. On GET on /login I get this error on the page

ErrorException in a19535dcda3ed1d86f3228aa05198ae78974da4f.php line 12:
Undefined variable: errors (View: /Applications/MAMP/htdocs/gos-twilio/server-laravel/resources/views/auth/login.blade.php)
in a19535dcda3ed1d86f3228aa05198ae78974da4f.php line 12
at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
at PhpEngine->evaluatePath('/Applications/MAMP/htdocs/gos-twilio/server-laravel/storage/framework/views/a19535dcda3ed1d86f3228aa05198ae78974da4f.php', array('__env' => object(Factory), 'app' => object(Application))) in CompilerEngine.php line 59

and no errors in php_error.log. On POST /login I can get my own output, from my custom method in AuthController but I doubt anything applies to it, such as automatic connection to the User model, login throttling etc, since I created my own method for this request inside the /http/controller/auth/AuthController.php called protected function login() What am I doing wrong? This is the output of php artisan route:list :

+--------+----------+-------------------------+----------------+-----------------------------------------------------------------+------------+
| Domain | Method   | URI                     | Name           | Action                                                          | Middleware |
+--------+----------+-------------------------+----------------+-----------------------------------------------------------------+------------+
|        | GET|HEAD | /                       | home           | Closure                                                         |            |
|        | GET|HEAD | home                    |                | App\Http\Controllers\HomeController@index                       | auth       |
|        | GET|HEAD | login                   |                | App\Http\Controllers\Auth\AuthController@showLoginForm          | guest      |
|        | POST     | login                   |                | App\Http\Controllers\Auth\AuthController@login                  | guest      |
|        | GET|HEAD | logout                  |                | App\Http\Controllers\Auth\AuthController@logout                 |            |
|        | POST     | password/email          |                | App\Http\Controllers\Auth\PasswordController@sendResetLinkEmail | guest      |
|        | POST     | password/reset          |                | App\Http\Controllers\Auth\PasswordController@reset              | guest      |
|        | GET|HEAD | password/reset/{token?} |                | App\Http\Controllers\Auth\PasswordController@showResetForm      | guest      |
|        | GET|HEAD | register                |                | App\Http\Controllers\Auth\AuthController@showRegistrationForm   | guest      |
|        | POST     | register                |                | App\Http\Controllers\Auth\AuthController@register               | guest      |
|        | POST     | token                   | token-generate | App\Http\Controllers\TokenController@generate                   |            |
+--------+----------+-------------------------+----------------+-----------------------------------------------------------------+------------+

Routes are defined in app/http/routes.php which has this content:

<?php
Route::get(
    '/',
    ['as' => 'home', function () {
        return response()->view('index');
    }]
);
Route::post(
    '/token',
    ['uses' => 'TokenController@generate', 'as' => 'token-generate']
);
Route::auth();
Route::get('/home', 'HomeController@index');
Route::auth();
Route::get('/home', 'HomeController@index');
Route::auth();
Route::get('/home', 'HomeController@index');
Route::auth();
Route::get('/home', 'HomeController@index');


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire