Example #1
0
 public function beforeAction($action)
 {
     if (!in_array($action->id, $this->ignoreAction)) {
         if (is_object(Yii::$app->user->identity)) {
             if (adminUser::isUserAdmin(Yii::$app->user->identity->username) == 1) {
                 return $action;
             }
         } else {
             return $this->goHome();
         }
     }
     // $this->enableCsrfValidation = false;
     return parent::beforeAction($action);
 }
 /**
  * Finds the UsersRegister model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UsersRegister the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findAdminModel($id)
 {
     if (($model = adminUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function loginAdmin()
 {
     if ($this->validate() && adminUser::isUserAdmin($this->username)) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         return false;
     }
 }