我想为我的网络应用程序创建用户。
我正在使用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
或sfDoctrineGuardPlugin的目的是保护管理页面而不是前端日志记录系统?
感谢。
答案 0 :(得分:5)
我建议使用sfDoctrineGuardPlugin。它提供了在后端管理用户的表单。它可以轻松扩展以添加额外的数据库字段,为用户添加更多信息(配置文件等),并在为您存储用户密码时处理所有SHA / MD5密码加密。如果您从头开始创建登录系统,则需要考虑密码存储。
在构建安全页面时,这基本上是一个很好的起点。它可以用于后端和前端。对于前端,您只需要在配置文件中启用正确的模块,就可以毫无问题地使用它。
我忘记添加的一件事是sfDoctrineGuardPlugin还提供了“记住我”功能。哪个好。使用插件。 :)