Creating user roles

删除回忆录丶 提交于 2019-12-08 19:20:34

The sfDoctrineGuard plugin (http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin) is a pretty comprehensive way of handling user authentication, groups and credentials. Users can be set permissions either individually or as a group, and access to specific page sections or entire actions can be restricted based on those permissions. You can set new user credentials in the controller code itself, e.g.

<?php
$this->getUser()->setCredential('editor');
?>

And verify that a user has particular permissions in views:

<?php
if ($sf_user->hasCredential('editor')) {
  // stuff only for editors
}
?>

This page has lots of extra info on the plugin not covered by the readme file - http://trac.symfony-project.org/wiki/sfGuardPluginExtraDocumentation (although it refers to Propel rather than Doctrine). Also the following series of short tutorials is pretty useful:

http://www.finalconcept.com.au/article/view/symfony-user-management-sfdoctrineguard-installation

http://www.finalconcept.com.au/article/view/symfony-user-management-sfdoctrineguard-administration

http://www.finalconcept.com.au/article/view/symfony-user-management-sfdoctrineguard-securing-actions

And the Symfony tutorial page on users:

http://www.symfony-project.org/jobeet/1_4/Doctrine/en/13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!