【发布时间】:2015-10-29 11:23:57
【问题描述】:
我正在开发一个业务目录的 laravel web 应用程序。
这是我的场景。
http://localhost/genie-works/devojp/customer // 用户使用企业关键字搜索和
在http://localhost/genie-works/devojp/customer/search-result?keyword=apple&searchcity=1此页面中显示结果。
此处列出了太多带有发布查询功能的业务数据。
点击帖子时,查询按钮页面会转到http://localhost/genie-works/devojp/customer/post-enquiry/{bisinjessid}/
帖子查询页面检查中间件作为身份验证。
当用户未登录中间件时重定向到登录页面http://localhost/genie-works/devojp/customer并显示登录表单
输入登录详细信息后,需要重定向到http://localhost/genie-works/devojp/customer/post-enquiry/{bisinjessid}/此页面。
-
但我尝试了 Redirect::back 功能,将其重定向到客户页面 (http://localhost/genie-works/devojp/customer)
如何通过重定向到我的最后一页来解决此问题....
谢谢
中间件..
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return redirect()->intended(route('cust_index'))->with('activelogin','Succesfully LoggedOut !!!');
}
return $next($request);
}
控制器..
public function custdologin(){
$userdata=array(
'username'=>Input::get('email'), // getting data from form
'password'=>Input::get('password') // getting data from form
);
if(Auth::attempt($userdata)){
switch (Auth::user()->user_type) {
case '2':
return Redirect::to(route('myaccount'));
break;
case '3':
return back();
break;
default:
Auth::logout();
return Redirect::to(route('business_login'))->with('message','Check Your Entries!!');
break;
}
}
else
return Redirect::to(route('business_login'))->with('message','Check Your Entries!!');
}
【问题讨论】:
-
使用redirect()->intended()而不是重定向回来
标签: authentication laravel-5 middleware