예제 #1
0
 /**
  * @return SessionModel
  * @throws RuntimeErrorException
  */
 protected function makeSession()
 {
     $cookieToken = UUID::v5(mt_rand() . self::SALT);
     $this->cookies->set($this->cookieKey(), $cookieToken, $this->expiryDate()->getTimestamp())->send();
     $sessionModel = $this->getSessionModel()->setAuthId($this->getCredentialsModel()->getId())->setAdapter($this->name())->setAuthHash($this->makeHash($cookieToken))->setUserHash($this->uniqueToken())->setUserIp(ip2long($this->request->getClientAddress(true)))->setCreatedAt((new \DateTime())->format('Y-m-d H:i:s'))->setLastVisit((new \DateTime())->format('Y-m-d H:i:s'));
     if (!$sessionModel->save()) {
         throw new RuntimeErrorException("Session can not been saved. Check your models");
     }
     return $sessionModel;
 }
예제 #2
0
 /**
  * @param string $string
  * @return string
  */
 public function makeHash($string)
 {
     return UUID::v5(self::SALT . $string . self::SALT);
 }