public function store($code, $type)
 {
     $codeId = utils::generateUniqueId();
     $session = session::getInstance();
     $createTime = utils::datetimePHP2Mysql(time());
     $codes = $session->get('AliceSPA_VerificationCodes');
     if (empty($codes)) {
         $codes = [];
     }
     if (empty($codes[$type])) {
         $codes[$type] = [];
     }
     $codes[$type][$codeId] = ['Code' => $code, 'CreateTime' => $createTime];
     if ($session->set('AliceSPA_VerificationCodes', $codes) === false) {
         return false;
     }
     return $codeId;
 }
Пример #2
0
 public function loadSession($sessionId)
 {
     $db = db::getInstance();
     $session = null;
     if (!empty($sessionId)) {
         $sessionValidTime = configHelper::getCoreConfig()['sessionValidTime'];
         $sessions = $db->select('aspa_session', '*', ['AND' => ['id' => $sessionId, 'create_time[>]' => utils::datetimePHP2Mysql(time() - $sessionValidTime)]]);
         if (!empty($sessions)) {
             $session = $sessions[0]['session'];
             $session = json_decode($session, true);
         }
     }
     if ($session === null) {
         $sessionId = utils::generateUniqueId();
         $session = [];
         $db->insert('aspa_session', ['id' => $sessionId, 'session' => json_encode($session)]);
     }
     $this->setSession($session);
     return $sessionId;
 }