Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

Problema con middleware

Estas en el tema de Problema con middleware en el foro de Frameworks y PHP orientado a objetos en Foros del Web. hola amigos, necesito autenticar una aplicacion con ldap, estoy trabajando con laravel 5.1 y el paquete que utilice fue https://github.com/SaschaDens/ldap-connector , cuando autenticaba contra base ...
  #1 (permalink)  
Antiguo 20/08/2015, 15:27
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Problema con middleware

hola amigos, necesito autenticar una aplicacion con ldap, estoy trabajando con laravel 5.1 y el paquete que utilice fue https://github.com/SaschaDens/ldap-connector, cuando autenticaba contra base de datos utilizaba el siguiente middleware:

Código PHP:
Ver original
  1. //routes.php
  2. Route::group(['middleware' => 'auth'], function () {
  3.  
  4.     Route::resource('investigations', 'InvestigationController');
  5.    
  6. });
  7. Route::get('auth/login', 'Auth\AuthController@getLogin');
  8.  
  9. Route::post('auth/login',  function (Request $request) {
  10.  
  11.     if(Adldap::authenticate($request->input('username'), $request->input('password') ))
  12.     {
  13.        
  14.        $user = Adldap::users()->find($request->input('username'));
  15.        Session::set('userName', $user->displayname['0']);
  16.        return view('welcome');
  17.        
  18.     }
  19.  
  20. });
  21.  
  22. Route::get('auth/logout', ['as' => 'auth/logout', 'uses' => 'Auth\AuthController@getLogout']);

este es mi Middleware/Authenticate.php

Código PHP:
Ver original
  1. namespace App\Http\Middleware;
  2.  
  3. use Closure;
  4. use Illuminate\Contracts\Auth\Guard;
  5.  
  6. class Authenticate
  7. {
  8.     /**
  9.      * The Guard implementation.
  10.      *
  11.      * @var Guard
  12.      */
  13.     protected $auth;
  14.  
  15.     /**
  16.      * Create a new filter instance.
  17.      *
  18.      * @param  Guard  $auth
  19.      * @return void
  20.      */
  21.     public function __construct(Guard $auth)
  22.     {
  23.         $this->auth = $auth;
  24.     }
  25.  
  26.     /**
  27.      * Handle an incoming request.
  28.      *
  29.      * @param  \Illuminate\Http\Request  $request
  30.      * @param  \Closure  $next
  31.      * @return mixed
  32.      */
  33.     public function handle($request, Closure $next)
  34.     {
  35.         if ($this->auth->guest()) {
  36.             if ($request->ajax()) {
  37.                 return response('Unauthorized.', 401);
  38.             } else {
  39.                 return redirect()->guest('auth/login');
  40.             }
  41.         }
  42.  
  43.         return $next($request);
  44.     }
  45. }


ahora cuando ingreso al recurso investigations me redireccion al login, a que se debe esto?

Etiquetas: laravel
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:27.