所以我试图使用Laravel的自定义过滤器来验证我的用户。我有我的LDAP PHP脚本工作,我已基本上将其插入到我的自定义过滤器。但是,我需要通过此脚本输入用户在登录屏幕上输入的用户名和密码;换句话说,我需要通过我的自定义过滤器从登录表单中输入用户名和密码。具有多个参数的基本Laravel路由过滤
这里是我的代码,以帮助解释我的问题:
routes.php文件
Route::group(array('before' => 'ldapTest'), function() {
Route::controller('apps', 'AppController', array(
//named routes here
));
});
filters.php
Route::filter('ldapTest', function()
{
$username = //how do I get this?
$password = //how do I get this?
//LDAP logic goes here; assume $ldapConn and $userDN are properly initialized
$userBind = @ldap_bind($ldapConn, $userDN, $password);
if($userBind)
{
Auth::login(//what goes here? I want to access $username later on in applications);
return Redirect::to('apps/home');
}
else
{
echo 'Incorrect password';
}
});
从阅读文档我明白了,你可以将参数作为字符串传递给过滤器,如下所示:Route::filter('ldapTest:400', function()
,但我不明白我如何使用这个来传递我的用户名和密码,使用我认为是Input :: get()的方法。
我该怎么做?
您可以使用Input :: get('username')'来获取输入字段的值,有名称'用户名'。你为什么不使用它? – totymedli 2014-10-02 22:25:33