Advertisement
marioandrade

Laravel Login

Oct 1st, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. Route::post('login', function()
  2. {
  3.  
  4.     $email = Input::get('email');
  5.     $password = Input::get('password');
  6.     $hashedPassword = Hash::make( $password );
  7.  
  8.     if (Auth::attempt(array('User_Email' => $email, 'User_Password' => $hashedPassword ) ) )
  9.     {
  10.  
  11.     $user = User::find(1);
  12.         Auth::login($user);
  13.         return Redirect::intended('dashboard');
  14.     }
  15.  
  16.     return Redirect::intended('login')->with('flash_error', 'Invalid E-mail/Password');
  17.  
  18. });
  19.  
  20.  
  21. /* ############################## VIEW - login.blade.php */
  22.  
  23. @extends('backoffice.master')
  24.  
  25. @section('content')
  26.  
  27.     <div class="small-4 small-centered columns">
  28.  
  29.         @if (Session::has('flash_error'))
  30.             <div class="alert-box alert">{{ Session::get('flash_error') }}</div>
  31.         @endif
  32.  
  33.         <form method="POST" id="frmLogin">
  34.  
  35.  
  36.             <div class="large-12 columns">
  37.                 {{ Form::input('email', 'email', null, ['placeholder' => 'E-mail', 'aria-invalid' => 'false', 'id' => 'email'] ) }}
  38.  
  39.             </div>
  40.  
  41.             <div class="large-12 columns">
  42.                 {{ Form::input('password', 'password', null, ['placeholder' => 'Password', 'id' => 'password'] ) }}
  43.             </div>
  44.  
  45.             <div class="large-12 columns">
  46.                 <button id="submit" class="button large-12" type="submit" name="btn-submit">Login</button>
  47.             </div>
  48.         </form>
  49.     </div>
  50. @stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement