Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::get('admin/login', 'adminLoginController@showLogin'); // Mostrar login
- Route::post('admin/login', 'adminLoginController@postLogin'); // Verificar datos
- Route::get('admin/logout', 'adminLoginController@logOut'); // Finalizar sesión
- Route::group(['before' => 'auth'], function()
- {
- Route::get('admin', function (){
- });
- });
- namespace AppHttpControllersadmin;
- use IlluminateHttpRequest;
- use AppHttpControllersController;
- use DB;
- use Auth;
- use IlluminateSupportFacadesInput;
- class LoginController extends Controller{
- public function showLogin (){
- if (Auth::check()){
- return Redirect::to('/admin');
- }
- return view('admin/login');
- }
- public function postLogin(){
- $data = [
- 'username' => Input::get('username'),
- 'password' => Input::get('password')
- ];
- if (Auth::attempt($data, Input::get('remember')))
- {
- return Redirect::intended('admin');
- }
- return Redirect::back()->with('error_message', 'Invalid data')->withInput();
- }
- public function logOut(){
- Auth::logout();
- return Redirect::to('admin/login')->with('error_message', 'Logged out correctly');
- }
- }
Add Comment
Please, Sign In to add comment