Laravel 5.2 Authentication and Password Route

I saw Laravel 5.2 changing usage routes.php.

In fact, the old one:

Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);

now do not work.

Instead, I saw that it is better to use:

Route::Auth();

But this method does not provide a password and registers the route as it is used to ...

In fact, I am using the solution I saw in Stack Overflow using the get and post method:

// Authentication Routes...
Route::get('login', 'Auth\AuthController@showLoginForm');
[...]

// Registration Routes...
Route::get('register', 'Auth\AuthController@showRegistrationForm');
[...]

// Password Reset Routes...
Route::get('password/reset/{token?}','Auth\PasswordController@showResetForm');
[...]

This is pretty awful, so is it better to use the 5.2 route.php file for this new version of Laravel?

Thank you for your help!

+4
source share
5 answers

Starting with Laravel 5.2, the authentication system is much easier to start and run. You can simply run this command:

php artisan make:auth

: , .. Laravel Documentation. , , Laravel 5.2.

+9

/Laravel//SRC//Routing/router.php
auth ,

+3

..

Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
Route::get('auth/confirm/{token}', 'Auth\AuthController@getConfirm');

  Route::get('password/email', 'Auth\PasswordController@getEmail');
  Route::post('password/email', 'Auth\PasswordController@postEmail');


  Route::get('password/reset{token}','Auth\PasswordController@getReset');
  Route::post('password/reset', 'Auth\PasswordController@postReset');
+2

- / / . .

( ) . . , .

0

:

Route::get('auth/login', ['as'=>'getLogin', 'uses'=>'Auth\AuthController@showLoginForm'];
Route::post('auth/login', ['as'=>'postLogin', 'uses'=>'Auth\AuthController@postLogin'];

In Controller, create a public function:

public function showLoginForm() {
    return view('auth.login');
}

public function postLogin(Request $data) {
    $users = new User();
    $users->username = $data->txtUsername;
    ...
}
0
source

Source: https://habr.com/ru/post/1622114/


All Articles