diff options
Diffstat (limited to 'app/class/Modelauthtoken.php')
-rw-r--r-- | app/class/Modelauthtoken.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/class/Modelauthtoken.php b/app/class/Modelauthtoken.php index 0a55e64..18ef6a7 100644 --- a/app/class/Modelauthtoken.php +++ b/app/class/Modelauthtoken.php @@ -8,7 +8,7 @@ class Modelauthtoken extends Modeldb { const AUTHTOKEN_REPO_NAME = 'authtoken'; - + const AUTHTOKEN_ID_LENGTH = 30; public function __construct() { @@ -29,6 +29,14 @@ class Modelauthtoken extends Modeldb 'creationdate' => '1' ]; $tokendata = new Document($datas); + + $exist = true; + while ($exist !== false) { + $id = bin2hex(random_bytes(self::AUTHTOKEN_ID_LENGTH)); + $exist = $this->repo->findById($id); + } + + $tokendata->setId($id); return $this->repo->store($tokendata); } |