I was asked about how to make of 2-step-login at the comment column of the article of the “multi-Authentication" that I posted.
Then I try it.

Outline I create this time is below

not login → login as user → login as Admin
According to login stage, you can see more pages.

■github – my-blog-161117__2step-login

(i) create multi-Authentication with my article

■How to make the multi-Authentication in laravel 5.2

(ii) edit route


Route::group(['middleware' => 'auth'], function () {

Grouping all admin route with middleware 'auth’.
And when you see admin page without login as user,
you need user login at first.

(iii) when you logout as user, automatically you logout as admin.

■github – logout as admin when logout as user


$this->get('logout', 'Auth\AuthController@logoutAll');

when you move to /logout, logoutAll method is executed.
modify route.


$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
$this->middleware($this->guestMiddleware(), ['except' => 'logoutAll']);

change middleware except from logout to logoutAll.
and add logoutAll method to the controller.

That’s all.
2-step-login is done.


Posted by dog-ears