Beispiel #1
0
 /**
  * Deletes an existing User model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     //if($id == '2') throw new HttpException(500, 'No Auth');
     User::updateAll(['status' => User::STATUS_DELETED], ['id' => $id]);
     //$this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
Beispiel #2
0
 public function setStatus($id, $status = 1)
 {
     if (!in_array($status, [0, 1]) || $id == 1) {
         return false;
     }
     return User::updateAll(['status' => $status], 'id = :id', [':id' => $id]);
 }
 /**
  * Activate
  *
  * <b>Request Type </b>: GET<br/>
  * <b>Request Endpoint </b>: http://{server-domain}/api/old-site/activate?code=abcd1234abcd1234<br/>
  *
  **/
 public function actionActivate()
 {
     $code = $this->getQuery('code');
     if (empty($code)) {
         $this->_activateFail(0);
         //此链接无效,请联系管理员
     }
     $validation = Validation::findOne(['code' => $code]);
     if (empty($validation)) {
         $this->_activateFail(0);
         //此链接无效,请联系管理员
     }
     if (empty($validation->expire) || MongodbUtil::isExpired($validation->expire)) {
         $this->_activateFail(1);
         //'此链接已过期,请联系管理员'
     }
     $userId = $validation->userId;
     if (User::updateAll(['isActivated' => User::ACTIVATED], ['_id' => $userId])) {
         $validation->delete();
         $this->redirect('/old/activate?type=0&link=' . urlencode('/site/login'));
         Yii::$app->end();
     }
     $this->_activateFail(1);
     //'此链接已过期,请联系管理员'
 }