使用sfDoctrineGuardPlugin进行常规会员登录?

nev*_*ame 1 authentication symfony1

我想为我的webapplication创建用户.

即时通讯使用symfony.我想知道我是否应该使用sfDoctrineGuardPlugin或symfony提供的方法呢?

// Add one or more credentials
$user->addCredential('foo');
$user->addCredentials('foo', 'bar');

// Check if the user has a credential
echo $user->hasCredential('foo');                      =>   true

// Check if the user has both credentials
echo $user->hasCredential(array('foo', 'bar'));        =>   true

// Check if the user has one of the credentials
echo $user->hasCredential(array('foo', 'bar'), false); =>   true

// Remove a credential
$user->removeCredential('foo');
echo $user->hasCredential('foo');                      =>   false

// Remove all credentials (useful in the logout process)
$user->clearCredentials();
echo $user->hasCredential('bar');                      =>   false
Run Code Online (Sandbox Code Playgroud)

或者sfDoctrineGuardPlugin的目的是保护管理页面而不是前端日志记录系统?

谢谢.

Pet*_*r D 5

我建议使用sfDoctrineGuardPlugin.它提供了在后端管理用户的表单.它可以轻松扩展以添加额外的数据库字段,为用户添加更多信息(配置文件等),并在为您存储用户密码时处理所有SHA/MD5密码加密.如果从头开始创建登录系统,则需要考虑密码存储.

在构建安全页面时,它基本上是一个很好的起点.它可以用于后端和前端.对于前端,您只需要在配置文件中启用正确的模块,您就可以毫无问题地使用它.

我忘记添加的一件事是sfDoctrineGuardPlugin还提供了"记住我"功能.哪个好.使用插件.:)

  • sfGuardPlugin使用propel,sfDoctrineGuardPlugin提供相同的功能,但使用了doctrine. (2认同)