public function signinAction() { $sAdminName = $this->getParam('username'); $sPassword = $this->getParam('password'); $bRemember = $this->getParam('remember'); $aUser = Model_Admin::getAdminByName($sAdminName); if (empty($aUser)) { return $this->showMsg('帐号不存在!', false); } if ($aUser['iStatus'] == 0) { return $this->showMsg('帐号被禁用!', false); } if ($aUser['sPassword'] != md5(Yaf_G::getConf('cryptkey', 'cookie') . $sPassword)) { return $this->showMsg('密码不正确!', false); } $aCookie = array('iAdminID' => $aUser['iAdminID'], 'iCityID' => $aUser['iCityID'], 'sAdminName' => $aUser['sAdminName'], 'sRealName' => $aUser['sRealName']); if ($bRemember) { $expire = 86400 * 7; } else { $expire = 0; } Util_Cookie::set(Yaf_G::getConf('authkey', 'cookie'), $aCookie, $expire); $aPermissions = Model_Permission::getUserPermissions($aCookie['iAdminID']); $sUrl = '/admin/user/info'; return $this->showMsg(['msg' => '登录成功!', 'sUrl' => $sUrl], true); }
/** * 增加用户 */ public function addAction() { if ($this->_request->isPost()) { $aUser = $this->_checkData('add'); if (empty($aUser)) { return null; } if (Model_Admin::getAdminByName($aUser['sAdminName'])) { return $this->showMsg('用户已经存在!', false); } if (Model_Admin::addData($aUser) > 0) { return $this->showMsg('用户增加成功!', true); } else { return $this->showMsg('用户增加失败!', false); } } else { $this->assign('aCity', Model_City::getPairCitys()); $this->assign('aRole', Model_Role::getPairRoles()); } }