Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. Route::group(['middleware' => ['web']], function () {
  2.  
  3. // Login, logout
  4. Route::get('admin', array('as' => 'login', 'uses' => 'AuthController@index'));
  5. Route::post('admin/login', array('as' => 'cms_login', 'uses' => 'AuthController@login', 'before' => 'csrf'));
  6. Route::get('admin/logout', array('as' => 'logout', 'uses' => 'AuthController@logout'));
  7.  
  8. ...
  9. }
  10.  
  11. public function index()
  12. {
  13. // Show login form
  14. return view('backend/pages/login');
  15. } // index()
  16.  
  17.  
  18. public function login(Request $request)
  19. {
  20.  
  21. // Form validation
  22. //
  23.  
  24. // Rules for the input fields:
  25. // - email: must be an valid email
  26. // - password: alpha nummeric with 6 characters minimum
  27. $validators = array(
  28. 'email' => 'required|email',
  29. 'password' => 'required|alphaNum|min:6'
  30. );
  31.  
  32. // Run the validators on the inputs fields
  33. $validator = Validator::make(Input::all(), $validators);
  34.  
  35. //
  36. // User validation
  37. //
  38.  
  39. // Get input fields values
  40. $email = Input::get('email');
  41. $password = Input::get('password');
  42.  
  43. // Log in if user credentials are valid
  44. if(Auth::attempt(array('email' => $email, 'password' => $password))) {
  45. return view('backend/pages/cms')
  46. }
  47. .....
  48.  
  49.  
  50. Doesn't matter what I do, I landing always on the home screen www.example.com
  51. if I try to call www.example.com/admin.
  52.  
  53. 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.
  54. Route::get('admin', function() {
  55. return view('backend/pages/login');
  56. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement