public function actionActivate($key)
 {
     if (!$key) {
         throw new CHttpException(404, "Activation key should be specified");
     }
     $confirmation = IdentityConfirmation::model()->findByAttributes(array('key' => $key));
     if (!$confirmation) {
         throw new CHttpException(404, "Specified confirmation was not found");
     }
     $confirmation->confirm();
     Yii::app()->user->setFlash('success', "Your account activated successfully. You can login now.");
     $this->redirect(array($this->module->loginUrl));
 }
示例#2
0
 /**
  * Instantiates particular subclass of IdentityConfirmation based on it's type
  * @todo:
  * - Replace this method by overriding afterFind method, where we can attach corresponding behaviour
  * @param type $id
  */
 public static function create($id)
 {
     $particularConfirmation = null;
     if (is_string($id)) {
         //creating by key
         $confirmation = IdentityConfirmation::model()->findByAttributes(array('key' => $id));
         if (!$confirmation) {
             return null;
         }
         if ($confirmation->type == IdentityConfirmation::TYPE_EMAIL_REPLACE_CONFIRMATION) {
             $particularConfirmation = new ReplaceEmailConfirmation();
             $particularConfirmation->setAttributes($confirmation->attributes, false);
             $particularConfirmation->isNewRecord = false;
         } else {
             $particularConfirmation = $confirmation;
         }
     }
     return $particularConfirmation;
 }