laravel build in auth specify view to use
Is there a way to specify what view to use for the built in auth in laravel? It currently uses views/auth/login.blade.php but i want for example to use views/admin/auth for the admin section then use another view for the front
Answer
when using the AuthenticatesUsers trait your controller will have getLogin, postLogin and getLogout methods which I think is what you are referencing on your routes, something like this:
Route::get('auth/login', 'Auth\[email protected]');
Route::post('auth/login', 'Auth\[email protected]');
Route::get('auth/logout', 'Auth\[email protected]');
If you give a look to AuthenticatesUsers the only thing it does is to check if view auth.authenticate exists if not it returns auth.login
You could override this method or create a new one with the view you want to return and change your route
class AuthController extends Controller
{
public function newLogin()
{
return view('admin.auth');
}
}
And change your Route to
Route::get('auth/login', 'Auth\[email protected]');
Another thing you could need in the future is to change the default login path and redirected after logout path, that can be done by defining in your controller two properties as protected:
protected $redirectAfterLogout = '/where/to/redirect/after/login';
protected $loginPath = '/another/login/path';
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?