1
0
mirror of https://github.com/r4sas/recastin-panel synced 2025-03-12 05:11:04 +00:00

Few updates:

limit usable chars in username at register
update stream name regex
make redirect on publish to user/stream/live instead leaving it with hash (makes possible to share direct stream link)
This commit is contained in:
R4SAS 2018-12-31 00:51:11 +03:00
parent 8bf12146b7
commit db4483d1f3
4 changed files with 22 additions and 7 deletions

View File

@ -42,4 +42,4 @@ class Stats
return [];
}
}
}

View File

@ -8,6 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Class Events
@ -53,7 +54,7 @@ class Events extends Controller
$manager->persist($stream);
$manager->flush();
return new Response();
return new RedirectResponse('live');
}
return new Response('', 401);
@ -108,4 +109,4 @@ class Events extends Controller
return $stream;
}
}
}

View File

@ -55,6 +55,10 @@ class Register extends Controller
$data = $request->request->all();
if (empty($data['username']) || !$this->isValidString($data['username'])) {
return new JsonResponse(['message' => 'Name is empty or contains illegal chars. Please use A-Z, a-z, 0-9, .-_'], 500);
}
if ($this->repository->findOneBy(['username' => $data['username']])) {
return new JsonResponse(['message' => 'Username is already taken'], 500);
}
@ -89,4 +93,14 @@ class Register extends Controller
{
return XmlUtils::phpize($this->container->getParameter('registrationEnabled'));
}
}
/**
* @param null|string $string
* @return false|int
* @author Soner Sayakci <shyim@posteo.de>
*/
private function isValidString(?string $string)
{
return preg_match('/^[A-Z|a-z|0-9|.|\-|_]+$/m', $string);
}
}

View File

@ -97,7 +97,7 @@ class Streams extends Controller
}
if (empty($requestBody['name']) || !$this->isValidString($requestBody['name'])) {
return new JsonResponse(['message' => 'Name is empty or contains illegal strings'], 500);
return new JsonResponse(['message' => 'Name is empty or contains illegal chars'], 500);
}
$stream->setUser($this->getUser());
@ -317,6 +317,6 @@ class Streams extends Controller
*/
private function isValidString(?string $string)
{
return preg_match('/^[a-z|A-Z|a-z|A-Z|0-9|.|\-|_|\{|\}|\:|\/|=|&|?]+$/m', $string);
return preg_match('/^[A-Z|a-z|0-9|.|\-|_|\{|\}|\:|\/|=|&|?]+$/m', $string);
}
}
}