mirror of https://github.com/sualko/cloud_bbb
53 lines
1.0 KiB
PHP
53 lines
1.0 KiB
PHP
|
<?php
|
||
|
namespace OCA\BigBlueButton\Middleware;
|
||
|
|
||
|
use OCA\BigBlueButton\Controller\JoinController;
|
||
|
use OCA\BigBlueButton\NotFoundException;
|
||
|
use OCP\AppFramework\Middleware;
|
||
|
use OCP\AppFramework\Http\NotFoundResponse;
|
||
|
use OCP\IRequest;
|
||
|
|
||
|
class JoinMiddleware extends Middleware
|
||
|
{
|
||
|
/** @var IRequest */
|
||
|
private $request;
|
||
|
|
||
|
public function __construct(IRequest $request)
|
||
|
{
|
||
|
$this->request = $request;
|
||
|
}
|
||
|
|
||
|
public function beforeController($controller, $methodName)
|
||
|
{
|
||
|
if (!($controller instanceof JoinController)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$token = $this->request->getParam('token');
|
||
|
if ($token === null) {
|
||
|
throw new NotFoundException();
|
||
|
}
|
||
|
|
||
|
$controller->setToken($token);
|
||
|
|
||
|
if ($controller->isValidToken()) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
throw new NotFoundException();
|
||
|
}
|
||
|
|
||
|
public function afterException($controller, $methodName, \Exception $exception)
|
||
|
{
|
||
|
if (!($controller instanceof JoinController)) {
|
||
|
throw $exception;
|
||
|
}
|
||
|
|
||
|
if ($exception instanceof NotFoundException) {
|
||
|
return new NotFoundResponse();
|
||
|
}
|
||
|
|
||
|
throw $exception;
|
||
|
}
|
||
|
}
|