forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CampCollaborationService: use random_bytes to generate inviteKey
Since 0b8204c, if a dot (.) is in the url and no slash is after that part of the path, this part is interpreted as file an a 404 is returned by the vite dev server. We did not test it in production. We anyway wanted to use the same id generator for the inviteKey as for the entities. Issue: ecamp#1238
- Loading branch information
Showing
3 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace eCamp\Lib\Util; | ||
|
||
use RuntimeException; | ||
|
||
class IdGenerator { | ||
public static function generateRandomHexString(int $length): string { | ||
try { | ||
return bin2hex(random_bytes($length / 2)); | ||
} catch (\Exception $e) { | ||
throw new RuntimeException($e); | ||
} | ||
} | ||
} |