protected function onInit_chkLogin() { $userIdentifier = \Sooh\Base\Session\Data::getInstance()->get('accountId'); if ($userIdentifier) { \Sooh\Base\Log\Data::getInstance()->userId = $userIdentifier; $this->user = \Prj\Data\User::getCopy($userIdentifier); } else { throw new \ErrorException(\Prj\ErrCode::errNotLogin, 401); } }
/** * 记录打开页面的情况 * * @input string page 页面名(标示) * @input string httpReferer httpReferer * @sample {api_uri}&page=intro.html&httpReferer=www.baidu.com * @return {"code":200,"msg":""} 正常情况 */ public function openpageAction() { $loger = \Sooh\Base\Log\Data::getInstance(); $loger->evt = 'openpage'; $loger->target = $this->_request->get('page'); $loger->userId = \Sooh\Base\Session\Data::getInstance()->get('accountId'); $loger->ext = $this->_request->get('httpReferer'); $this->_view->assign('code', '200'); $this->_view->assign('msg', ''); }
/** * @return array array(deviceid,userid) */ protected function initSession() { error_log('initSession called'); $rpc = $this->getRpcDefault('SessionStorage'); if ($rpc == null) { error_log('sessionStorage direct'); \Lib\Services\SessionStorage::setStorageIni('session', 2); } else { error_log('sessionStorage by rpc'); } \Sooh\Base\Session\Data::getInstance(\Lib\Services\SessionStorage::getInstance($rpc)); $deviceId = \Sooh\Base\Session\Data::getSessId(); $uid = \Sooh\Base\Session\Data::getInstance()->get('accountId'); return array($deviceId, $uid); }
public function indexAction() { \Lib\Services\SessionStorage::setStorageIni(); \Sooh\Base\Session\Data::getInstance(\Lib\Services\SessionStorage::getInstance($this->getRpcDefault('SessionStorage'))); \Sooh\Base\Ini::getInstance()->viewRenderType('json'); $this->_view->assign('normal', true); $this->_view->assign('sessionId', \Sooh\Base\Session\Data::getSessId()); $this->_view->assign('accountId', \Sooh\Base\Session\Data::getInstance()->get('accountId')); $today = \Sooh\Base\Time::getInstance()->YmdFull; $uri0 = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '' . $_SERVER["SCRIPT_NAME"]; $this->_view->assign('urls', array('login' => $uri0 . '?__=passport/login&loginname=qq01&passwd=123456', 'register' => $uri0 . '?__=passport/register&loginname=qq01&passwd=123456&contractId=34562342523534', 'checkin-checkin' => $uri0 . '?__=checkin/checkin&with_bonus=1', 'checkin-today' => $uri0 . '?__=checkin/today&with_bonus=1', 'checkin-reset' => $uri0 . '?__=checkin/resetday&ymd=' . $today, 'checkin-resetAll' => $uri0 . '?__=checkin/resetday&ymd=' . $today . '&num=0')); //$this->_view->assign('code1',\Lib\Subdir\Abc::run()); throw new \ErrorException('msg append by exception'); //$this->_view->assign('code2', \Subdir\Test::run()); //$this->_view->assign('code3',\Subdir_Type1::run()); }
public function indexAction() { if ($this->_request->get('dowhat') == 'logout') { $this->_view->assign('useTpl', 'logout'); \Sooh\Base\Session\Data::getInstance()->set('managerId', ''); } elseif ($this->manager) { //已经登入,进主页 $this->manager->load(); $this->_view->assign('leftmenus', $this->manager->acl->getMenuMine()); $this->_view->assign('useTpl', 'homepage'); } else { //尚未登入,去登入页 $u = $this->_request->get('u'); $p = $this->_request->get('p'); if (!empty($u) && !empty($p)) { $this->ini->viewRenderType('json'); $acc = \Lib\Services\Manager::getInstance(null); try { $validImg = $this->_request->get('valid'); $sessionData = \Sooh\Base\Session\Data::getInstance(); if ($validImg !== $sessionData->get('validImg')) { return $this->returnError('invalidCode'); } $accountInfo = $acc->login($u, $p, 'local', array('rights')); $log = \Sooh\Base\Log\Data::getInstance(); $log->ret = 'login ok'; $log->ext = $accountInfo['nickname']; $sessionData->set('managerId', $accountInfo['accountId']); $sessionData->set('nickname', $accountInfo['nickname']); $this->returnOK(); } catch (\Exception $e) { \Sooh\Base\Log\Data::getInstance()->ret = $e->getMessage(); $this->returnError($e->getMessage()); } } else { $acc = \Lib\Services\Manager::getInstance(null); $acc->addFirstAccount(); $this->_view->assign('useTpl', 'login'); } } }
protected function onLogin($accountInfo) { $sess = \Sooh\Base\Session\Data::getInstance(); $sess->set('accountId', $accountInfo['accountId']); $sess->set('nickname', $accountInfo['nickname']); $this->_view->assign('account', array('accountId' => $accountInfo['accountId'], 'nickname' => $accountInfo['nickname'])); /** $userOrAccountId = $this->user; $checkinBook = \Lib\Services\CheckinBook::getInstance(); */ $userOrAccountId = $accountInfo['accountId']; $checkinBook = \Lib\Services\CheckinBook::getInstance($this->getRpcDefault('CheckinBook')); $this->_view->assign('checkinBook', $checkinBook->doGetTodayStatus(1, $userOrAccountId)['data']); $this->_view->assign('shopPoints', array('nleft' => 'todo', 'history' => array('todo'))); $user = \Prj\Data\User::getCopy($userOrAccountId); setcookie('nickname', $accountInfo['nickname'], 0, '/', \Sooh\Base\Ini::getInstance()->cookieDomain()); $user->load(); $dt = \Sooh\Base\Time::getInstance(); if ($user->exists() === false) { $user->setField('nickname', $accountInfo['nickname']); $user->setField('contractId', $accountInfo['contractId']); $user->setField('regYmd', $dt->YmdFull); $user->setField('regHHiiss', $dt->his); $user->setField('regClient', self::tmp_clientType); $user->setField('regIP', \Sooh\Base\Tools::remoteIP()); //$user->setField(self::fieldUser, array()); $user->update(); } else { $user->setField('nickname', $accountInfo['nickname']); $user->setField('lastDt', $dt->timestamp()); $user->setField('lastIP', \Sooh\Base\Tools::remoteIP()); $user->update(); } $sess->shutdown(); $this->returnOK(); }
protected function onInit_chkLogin() { $this->session = \Sooh\Base\Session\Data::getInstance(); if ($this->session) { $userId = $this->session->get('managerId'); if ($userId) { \Sooh\Base\Log\Data::getInstance()->userId = $userId; $this->manager = \Prj\Data\Manager::getCopyByManagerId($userId); $this->manager->load(); if (!$this->manager->acl->hasRightsFor($this->_request->getModuleName(), $this->_request->getControllerName())) { $this->returnError(\Prj\ErrCode::errNoRights, 300); } } else { $this->returnError(\Prj\ErrCode::errNotLogin, 301); } } }