Código PHP:
Ver original
//routes.php Route::group(['middleware' => 'auth'], function () { Route::resource('investigations', 'InvestigationController'); }); Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', function (Request $request) { if(Adldap::authenticate($request->input('username'), $request->input('password') )) { $user = Adldap::users()->find($request->input('username')); Session::set('userName', $user->displayname['0']); return view('welcome'); } }); Route::get('auth/logout', ['as' => 'auth/logout', 'uses' => 'Auth\AuthController@getLogout']);
este es mi Middleware/Authenticate.php
Código PHP:
Ver original
namespace App\Http\Middleware; use Closure; use Illuminate\Contracts\Auth\Guard; class Authenticate { /** * The Guard implementation. * * @var Guard */ protected $auth; /** * Create a new filter instance. * * @param Guard $auth * @return void */ public function __construct(Guard $auth) { $this->auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest('auth/login'); } } return $next($request); } }
ahora cuando ingreso al recurso investigations me redireccion al login, a que se debe esto?