Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::group(['middleware' => ['web']], function () {
- // Login, logout
- Route::get('admin', array('as' => 'login', 'uses' => 'AuthController@index'));
- Route::post('admin/login', array('as' => 'cms_login', 'uses' => 'AuthController@login', 'before' => 'csrf'));
- Route::get('admin/logout', array('as' => 'logout', 'uses' => 'AuthController@logout'));
- ...
- }
- public function index()
- {
- // Show login form
- return view('backend/pages/login');
- } // index()
- public function login(Request $request)
- {
- // Form validation
- //
- // Rules for the input fields:
- // - email: must be an valid email
- // - password: alpha nummeric with 6 characters minimum
- $validators = array(
- 'email' => 'required|email',
- 'password' => 'required|alphaNum|min:6'
- );
- // Run the validators on the inputs fields
- $validator = Validator::make(Input::all(), $validators);
- //
- // User validation
- //
- // Get input fields values
- $email = Input::get('email');
- $password = Input::get('password');
- // Log in if user credentials are valid
- if(Auth::attempt(array('email' => $email, 'password' => $password))) {
- return view('backend/pages/cms')
- }
- .....
- Doesn't matter what I do, I landing always on the home screen www.example.com
- if I try to call www.example.com/admin.
- If I using this kind of route, I'm landing on the login form site, but if I click on "login" I'm landing again on the first page.
- Route::get('admin', function() {
- return view('backend/pages/login');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement