我创造我自己的博客引擎学习Symfony的,我有一个问题:允许用户更改自己的密码,电子邮件和个人
我可以添加和编辑用户感谢sfGuardUser模块,但我如何让用户只编辑他们的reccord?
用户应该有权访问允许他们编辑电子邮件,姓名,密码和个人资料的页面。
任何想法?
我创造我自己的博客引擎学习Symfony的,我有一个问题:允许用户更改自己的密码,电子邮件和个人
我可以添加和编辑用户感谢sfGuardUser模块,但我如何让用户只编辑他们的reccord?
用户应该有权访问允许他们编辑电子邮件,姓名,密码和个人资料的页面。
任何想法?
我发现下面的代码,今晚会试一下。
class sfGuardUserActions extends autoSfGuardUserActions {
public function executeEdit(sfWebRequest $request) {
$this->checkPerm($request);
parent::executeEdit($request);
}
public function checkPerm(sfWebRequest $request) {
$id = $request->getParameter('id');
$user = sfContext::getInstance()->getUser();
$user_id = $user->getGuardUser()->getId();
if ($id != $user_id && !($user->hasCredential('admin'))) {
$this->redirect('sfGuardAuth/secure');
}
} }
在更新配置文件的操作中,通过getId()
方法检索用户对象,并将更改应用于返回的对象。
$user = sfGuardUserPeer::retrieveByPK(
$this->getUser()->getGuardUser()->getId()
);
这是通过禁止用户编辑其他用户的个人资料,但并不正确保存用户信息 – Manu 2011-01-31 14:42:23