当前位置: 首页>>代码示例>>PHP>>正文


PHP Admin::addError方法代码示例

本文整理汇总了PHP中Admin::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::addError方法的具体用法?PHP Admin::addError怎么用?PHP Admin::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Admin的用法示例。


在下文中一共展示了Admin::addError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionLogin

 /**
  * 会员登录
  */
 public function actionLogin()
 {
     $model = new Admin('login');
     if (XUtils::method() == 'POST') {
         $model->attributes = $_POST['Admin'];
         if ($model->validate()) {
             $data = $model->find('username=:username', array('username' => $model->username));
             if ($data === null) {
                 $model->addError('username', '用户不存在');
                 AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0));
             } elseif (!$model->validatePassword($data->password)) {
                 $model->addError('password', '密码不正确');
                 AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0));
             } elseif ($data->group_id == 2) {
                 $model->addError('username', '用户被锁定,请联系网站管理');
             } else {
                 parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->username, 'groupId' => $data->group_id, 'super' => $data->group_id == 1 ? 1 : 0), array('prefix' => '_admini'));
                 $data->last_login_ip = XUtils::getClientIP();
                 $data->last_login_time = time();
                 $data->login_count = $data->login_count + 1;
                 $data->save();
                 AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->username)));
                 $this->redirect(array('default/index'));
             }
         }
     }
     $this->render('login', array('model' => $model));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:31,代码来源:PublicController.php

示例2: actionLogin

 public function actionLogin()
 {
     $model = new Admin('login');
     if (XUtils::method() == 'POST') {
         $model->attributes = $_POST['Admin'];
         if ($model->validate()) {
             $data = $model->find('username=:username', array('username' => $model->username));
             if ($data === null) {
                 $model->addError('username', '用户不存在');
                 parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0));
             } elseif (!$model->validatePassword($data->password)) {
                 $model->addError('password', '密码不正确');
                 parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0));
             } elseif ($data->group_id == 2) {
                 $model->addError('username', '用户已经锁定,请联系管理');
             } else {
                 $this->_sessionSet('_backendGroupId', $data->group_id);
                 if (isset($data->group_id) && $data->group_id == 1) {
                     $this->_sessionSet('_backendPermission', 'backendstrator');
                 }
                 $data->last_login_ip = XUtils::getClientIP();
                 $data->last_login_time = time();
                 $data->login_count = $data->login_count + 1;
                 $data->save();
                 parent::_sessionSet('uid', $data->id);
                 parent::_sessionSet('uname', $data->username);
                 parent::_backendLogger(array('catalog' => 'login', 'intro' => '用户登录成功:' . $data->username));
                 $this->redirect(array('default/index'));
                 XUtils::message('success', '登录成功', $this->createUrl('default/index'), 2);
             }
         }
     }
     $this->render('login', array('model' => $model));
 }
开发者ID:lp19851119,项目名称:114la,代码行数:34,代码来源:PublicController.php

示例3: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $model = new Admin('login');
     $model->attributes = $_POST['LoginForm'];
     if ($model->validate()) {
         $data = $model->find('username=:username', array('username' => $model->username));
         if ($data === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
             $model->addError('username', '用户不存在');
             parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . $model->username, 'user_id' => 0));
         } elseif (!$this->validatePassword($data->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
             $model->addError('password', '密码不正确');
             parent::_backendLogger(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . $model->username . ',使用密码:' . $model->password, 'user_id' => 0));
         } elseif ($data->group_id == 2) {
             $this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
             $model->addError('username', '用户已经锁定,请联系管理');
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode;
 }
开发者ID:lp19851119,项目名称:114la,代码行数:31,代码来源:UserIdentity.php

示例4: actionIndex

 public function actionIndex()
 {
     $model = new Admin('login');
     if (isset($_POST['Admin'])) {
         $model->attributes = $_POST['Admin'];
         if ($model->validate()) {
             $data = $model->find('username=:username', array('username' => $model->username));
             if ($data === null) {
                 $model->addError('username', '用户不存在');
             } elseif (!$model->validatePassword($data->password)) {
                 $model->addError('password', '密码不正确');
             } elseif ($data->group_id == 2) {
                 $model->addError('username', '用户被锁定,请联系网站管理');
             } else {
                 $_SESSION['_admini'] = array('userId' => $data->id, 'userName' => $data->username, 'groupId' => $data->group_id, 'super' => $data->group_id == 1 ? 1 : 0);
                 $data->last_login_time = time();
                 $data->login_count = $data->login_count + 1;
                 $data->save();
                 $this->redirect(array('main/index'));
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
开发者ID:njz817,项目名称:ycms,代码行数:24,代码来源:DefaultController.php


注:本文中的Admin::addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。