Jump to content
Larry Ullman's Book Forums

Recommended Posts

How does the code below (p. 268) work? Is it definitely correct? Can someone walk me through this? 
In actionSetup (A): Why is updateUser a child of updateOwnUser? Doesn't that mean anyone who can update his/her OWN user info can also update anyone else's? 
In the controller (B): Why is checkAccess (array('id' => $id)) used on updateUser instead of updateOwnUser? Does updateUser even use the ID parameter?
Please help - thanks...
Quite confused!
Code A:
# protected/controllers/SiteController.php::actionSetup()
$auth = Yii::app()->authManager;
// Create operations.
$task = $auth->createTask('updateOwnUser',
'Allows a user to update her record',
'return $params["id"] == Yii::app()->user->id;');
Code B:
# protected/controllers/UserController.php
public actionUpdate($id) {
if (!Yii::app()->user->checkAccess('updateUser',
array('id' => $id))) {
throw new CHttpException(403,
'You are not allowed to do this.');
// Code for doing this.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...