when i am trying to apply middleware on my routes like:
Route::get('twitterlogin','TwitterController@gettwitterlogin'); Route::post('twitterlogin','TwitterController@posttwitterlogin'); Route::group(['middleware'=>'auth'],function() { Route::get('twitternewsfeed','TwitterController@gettwitternewsfeed'); Route::post('postimage','TwitterController@postimage'); Route::post('posttweet','TwitterController@posttweet'); Route::get('twitterlogout','TwitterController@gettwitterlogout'); Route::post('editprofilepic','TwitterController@posteditprofilepic'); Route::post('searchuser','TwitterController@postsearchuser'); Route::post('edittweet{id}','TwitterController@postedittweet'); Route::get('deletetweet{id}','TwitterController@getdeletetweet'); Route::post('editprofile','TwitterController@posteditprofile'); Route::get('userprofile{email}','TwitterController@getuserprofile'); });
And when i am trying to submit my login form it does not bring me on next page it again opens the login page....what is the exact problem in this.My authenticate middleware is as follows....
namespace App\Http\Middleware;
use Closure; use Illuminate\Contracts\Auth\Guard;
class Authenticate { /** * The Guard implementation. * * @var Guard */ protected $auth;
/**
* Create a new middleware 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('twitterlogin');
}
}
return $next($request);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire