In my app I have two types of users - admin and teacher. In my AuthController I have this :
public function getLogin() {
retu view('auth.login');
}
public function postLogin(IlluminateHttpRequest $request) {
if(Auth::attempt([
'useame' => $request->input('useame'),
'password' => $request->input('password'),
'type' => 'admin'
])) {
retu redirect ('admin');
}
if(Auth::attempt([
'useame' => $request->input('useame'),
'password' => $request->input('password'),
'type' => 'teacher'
])) {
retu redirect ('educator/account');
}
retu redirect('login')->with('message', [
'type' => 'danger',
'message' => 'Грешно потребителско име или парола!'
]);
}
public function getLogout() {
Auth::logout();
retu redirect('login');
}
But when I'm logged in as a user with type teacher if i go to http://localhost/school_system/public/admin I automatically go to the admin panel without asking for useame and password. I want if I want to go to the admin panel from the teacher account this to happen with asking for useame and password, how can I make this?
My routes:
Route::group(['middleware' => ['auth']
], function () {
Route::group([
'prefix' => 'admin',
'namespace' => 'Admin'
], function () {
Route::controller('student', 'StudentsController');
Route::controller('profile', 'ProfilesController');
Route::controller('class', 'ClassesController');
Route::controller('subjects', 'SubjectsController');
Route::controller('teacher', 'TeachersController');
Route::controller('marktype', 'MarkTypeController');
Route::controller('rules', 'RuleController');
Route::get('{slug?}', 'PageController@getView');
});
});
Route::group(['middleware' => ['auth']
], function () {
Route::group([
'prefix' => 'educator',
'namespace' => 'Educator'
], function () {
Route::controller('account', 'AccountController');
Route::get('{slug?}', 'EducatorController@getView');
});
});
Thanks ^^
