Process token retrieve through Slim controller
This commit is contained in:
parent
1b8620b1ad
commit
764d34a7d3
5 changed files with 71 additions and 4 deletions
application/front/controller/admin
26
application/front/controller/admin/TokenController.php
Normal file
26
application/front/controller/admin/TokenController.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
/**
|
||||
* Class TokenController
|
||||
*
|
||||
* Endpoint used to retrieve a XSRF token. Useful for AJAX requests.
|
||||
*/
|
||||
class TokenController extends ShaarliAdminController
|
||||
{
|
||||
/**
|
||||
* GET /admin/token
|
||||
*/
|
||||
public function getToken(Request $request, Response $response): Response
|
||||
{
|
||||
$response = $response->withHeader('Content-Type', 'text/plain');
|
||||
|
||||
return $response->write($this->container->sessionManager->generateToken());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue