Esempio n. 1
0
 /**
  * Generates a new token.
  *
  * @access  protected
  * @return  string
  */
 protected function generateToken()
 {
     if (!$this->exists) {
         throw new LogicException(vsprintf("%s(): You can only generate auth tokens for users that exist in the database.", [__METHOD__]));
     }
     return hash('sha256', UUID::v4() . $this->getId() . uniqid('token', true));
 }
Esempio n. 2
0
 /**
  * Generates a session id.
  *
  * @access  protected
  * @return  string
  */
 protected function generateId()
 {
     return hash('sha256', UUID::v4() . uniqid('session', true));
 }
Esempio n. 3
0
 /**
  * Checks that the field value is a valid UUID.
  *
  * @access  protected
  * @param   string     $input  Field value
  * @return  boolean
  */
 protected function validateUuid($input)
 {
     return UUID::validate($input);
 }
Esempio n. 4
0
 /**
  *
  */
 public function testUUIDKey()
 {
     $uuid = UUIDKey::create(['value' => 'foo']);
     $this->assertTrue(UUID::validate($uuid->id));
     $uuid = UUIDKey::first();
     $this->assertTrue(UUID::validate($uuid->id));
 }
Esempio n. 5
0
 /**
  * Inserts a new record into the database.
  *
  * @access  protected
  * @param   \mako\database\midgard\Query  $query  Query builder
  */
 protected function insertRecord($query)
 {
     if ($this->primaryKeyType === static::PRIMARY_KEY_TYPE_INCREMENTING) {
         $this->columns[$this->primaryKey] = $query->insertAndGetId($this->columns, $this->primaryKey);
     } else {
         switch ($this->primaryKeyType) {
             case static::PRIMARY_KEY_TYPE_UUID:
                 $this->columns[$this->primaryKey] = UUID::v4();
                 break;
             case static::PRIMARY_KEY_TYPE_CUSTOM:
                 $this->columns[$this->primaryKey] = $this->generatePrimaryKey();
                 break;
         }
         $query->insert($this->columns);
     }
 }
Esempio n. 6
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testV5WithInvalidNamespace()
 {
     UUID::v5('nope', 'foobar');
 }