shorten public links to 8 characters
Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
Родитель
f1accf4585
Коммит
32884fd867
|
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||||
- Added qr code for public shares
|
- Added qr code for public shares
|
||||||
### Changes
|
### Changes
|
||||||
- PHP 8.0 as minimum requirement
|
- PHP 8.0 as minimum requirement
|
||||||
|
- Shorten public tokens to 8 characters (lower and upper characters and digits)
|
||||||
|
|
||||||
## [4.1.5] - 2023-02-25
|
## [4.1.5] - 2023-02-25
|
||||||
### Fix
|
### Fix
|
||||||
|
|
|
@ -422,12 +422,30 @@ class ShareService {
|
||||||
string $timeZone = ''
|
string $timeZone = ''
|
||||||
): Share {
|
): Share {
|
||||||
$preventInvitation = $userGroup->getType() === UserBase::TYPE_PUBLIC ?: $preventInvitation;
|
$preventInvitation = $userGroup->getType() === UserBase::TYPE_PUBLIC ?: $preventInvitation;
|
||||||
$token = $this->secureRandom->generate(
|
|
||||||
16,
|
$token = null;
|
||||||
ISecureRandom::CHAR_DIGITS .
|
$loopCounter = 0;
|
||||||
ISecureRandom::CHAR_LOWER .
|
// Generate a unique id
|
||||||
ISecureRandom::CHAR_UPPER
|
while (!$token) {
|
||||||
);
|
$loopCounter++;
|
||||||
|
$token = $this->secureRandom->generate(
|
||||||
|
8,
|
||||||
|
ISecureRandom::CHAR_DIGITS .
|
||||||
|
ISecureRandom::CHAR_LOWER .
|
||||||
|
ISecureRandom::CHAR_UPPER
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
$this->shareMapper->findByToken($token);
|
||||||
|
// reset token, if it already exists
|
||||||
|
$token = null;
|
||||||
|
} catch (ShareNotFoundException) {
|
||||||
|
$loopCounter = 0;
|
||||||
|
}
|
||||||
|
if ($loopCounter > 10) {
|
||||||
|
// In case of uninspected situations, avoid an endless loop
|
||||||
|
throw new \Exception('Unexpected loop count while trying to create a token for a new share');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->share = new Share();
|
$this->share = new Share();
|
||||||
$this->share->setToken($token);
|
$this->share->setToken($token);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче