Пример #1
0
 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);
 }