mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Replaced key variable with token
This commit is contained in:
@@ -31,10 +31,10 @@ class Permalink extends AbstractDelivery
|
||||
|
||||
$that = $this;
|
||||
|
||||
$deliverPermaview = function($sbas_id, $record_id, $key, $subdef, PhraseaApplication $app) {
|
||||
$deliverPermaview = function($sbas_id, $record_id, $token, $subdef, PhraseaApplication $app) {
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||
|
||||
if (!$record instanceof \record_adapter) {
|
||||
throw new \Exception_NotFound('bad luck');
|
||||
@@ -51,9 +51,9 @@ class Permalink extends AbstractDelivery
|
||||
return $app['twig']->render('overview.html.twig', $params);
|
||||
};
|
||||
|
||||
$deliverPermalink = function(PhraseaApplication $app, $sbas_id, $record_id, $key, $subdef) use ($that) {
|
||||
$deliverPermalink = function(PhraseaApplication $app, $sbas_id, $record_id, $token, $subdef) use ($that) {
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||
|
||||
if (!($record instanceof \record_adapter)) {
|
||||
throw new \Exception_NotFound('bad luck');
|
||||
@@ -78,7 +78,7 @@ class Permalink extends AbstractDelivery
|
||||
}
|
||||
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||
|
||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'key' => $key));
|
||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token));
|
||||
$response->headers->set('Link', $linkToCaption);
|
||||
|
||||
return $response;
|
||||
@@ -100,18 +100,18 @@ class Permalink extends AbstractDelivery
|
||||
|
||||
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||
|
||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'key' => $key));
|
||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token));
|
||||
$response->headers->set('Link', $linkToCaption);
|
||||
|
||||
return $response;
|
||||
};
|
||||
|
||||
$controllers->get('/v1/{sbas_id}/{record_id}/caption/', function(PhraseaApplication $app, Request $request, $sbas_id, $record_id) {
|
||||
$key = $request->query->get('token');
|
||||
$token = $request->query->get('token');
|
||||
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, 'thumbnail');
|
||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, 'thumbnail');
|
||||
if (null === $record) {
|
||||
throw new NotFoundHttpException("Caption not found");
|
||||
}
|
||||
@@ -123,23 +123,23 @@ class Permalink extends AbstractDelivery
|
||||
->bind('view_caption');
|
||||
|
||||
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef) use ($deliverPermaview) {
|
||||
$key = $request->query->get('token');
|
||||
$token = $request->query->get('token');
|
||||
|
||||
return $deliverPermaview($sbas_id, $record_id, $key, $subdef, $app);
|
||||
return $deliverPermaview($sbas_id, $record_id, $token, $subdef, $app);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $key, $subdef) use ($deliverPermaview) {
|
||||
return $deliverPermaview($sbas_id, $record_id, $key, $subdef, $app);
|
||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $token, $subdef) use ($deliverPermaview) {
|
||||
return $deliverPermaview($sbas_id, $record_id, $token, $subdef, $app);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/{label}', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef, $label) use ($deliverPermalink) {
|
||||
$key = $request->query->get('token');
|
||||
$token = $request->query->get('token');
|
||||
|
||||
return $deliverPermalink($app, $sbas_id, $record_id, $key, $subdef);
|
||||
return $deliverPermalink($app, $sbas_id, $record_id, $token, $subdef);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $key, $subdef) use ($deliverPermalink) {
|
||||
return $deliverPermalink($app, $sbas_id, $record_id, $key, $subdef);
|
||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $token, $subdef) use ($deliverPermalink) {
|
||||
return $deliverPermalink($app, $sbas_id, $record_id, $token, $subdef);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
return $controllers;
|
||||
|
@@ -185,7 +185,7 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
$this->assertEquals($response->headers->get($name), $value);
|
||||
}
|
||||
|
||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?key=".$token);
|
||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
$this->assertEquals($response->headers->get($name), $value);
|
||||
}
|
||||
|
||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?key=".$token);
|
||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user