我在Laravel 4.2中使用multiauth和两个表admin_profile和公司 .
public function Login()
{
$LoginData = Input::except(array('_token'));
//return $LoginData;
if (Input::get('username')=='' || Input::get('password')=='')
{
if(!$LoginData['CompanyURL']=='')
return Redirect::to('')->withInput()->with('Message', 'Enter Username and Password');
else
return Redirect::to('company/'.$LoginData['CompanyURL'])->withInput()->with('Message', 'Enter Username and Password');
}
//Admin User
if($LoginData['CompanyURL']=='')
{
if (Auth::admin()->attempt(array_filter($LoginData)))
{
$UserDetails = User::where('username', Input::get('username'))->first();
if(count($UserDetails)>0)
return Redirect::intended('home');
}
else
return Redirect::to('')->withInput()->with('Message', 'UserName or Password Invalid');
}
else
{
if (Auth::user()->attempt($LoginData))
{
//return $LoginData;
$CompanyModel = User::where('username', Input::get('username'))->first();
return Redirect::intended('company/'.$LoginData['CompanyURL'].'/home');
}
return Redirect::to('company/'.$LoginData['CompanyURL'])->withInput()->with('Message', 'UserName or Password Invalid');
}
}
但是我无法检查是否有任何类型为admin或company的用户登录以打开需要用户身份验证的主页等页面
如何更改此Route :: group(array('before'=>'auth'),function()
1 回答
您必须更改过滤器,请检查示例以了解如何修复它https://gist.github.com/ollieread/8303638
此外,如果您只想对常用页面使用一个auth过滤器,那么您的解决方案是
我还建议您定义不同类型的过滤器,这些过滤器对于谁拥有路径权限非常有用,