Skip to content

Instantly share code, notes, and snippets.

@crisu83
Created December 23, 2012 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crisu83/4366301 to your computer and use it in GitHub Desktop.
Save crisu83/4366301 to your computer and use it in GitHub Desktop.
A single action from a work in progress AuthItemController.
<?php
public function actionDelete()
{
$request = Yii::app()->request;
if ($request->isPostRequest && isset($_GET['name']))
{
$name = $_GET['name'];
/* @var $am CAuthManager|AuthBehavior */
$am = Yii::app()->getAuthManager();
$item = $am->getAuthItem($name);
$type = $item->getType();
if ($item instanceof CAuthItem)
$am->removeAuthItem($name);
if (!$request->isAjaxRequest)
$this->redirect(array('index', 'type'=>$type));
}
else
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment