Example #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));
 }
Example #2
0
 /**
  * Generates a session id.
  *
  * @access  protected
  * @return  string
  */
 protected function generateId()
 {
     return hash('sha256', UUID::v4() . uniqid('session', true));
 }
Example #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);
 }
Example #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));
 }
Example #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);
     }
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testV5WithInvalidNamespace()
 {
     UUID::v5('nope', 'foobar');
 }