Hello,
I’m trying to dev a public page for my app. So I’ve find the PublicShareController in the documentation but i’m not sure to understand how to use it. Here is my controller and my route :
<?php
namespace OCA\SOCApi\Controller;
use OCP\AppFramework\PublicShareController;
use OCP\IRequest;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Files\IRootFolder;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
class PublicAPIController extends PublicShareController {
private $storage;
private $userSession;
protected $session;
protected $request;
public function __construct(
string $AppName,
IRequest $request,
IUserManager $pwcheck,
IUserSession $UserSession,
ISession $session,
)
{
parent::__construct($AppName, $request, $session);
$this->storage = $storage;
$this->pwcheck = $pwcheck;
$this->userSession = $UserSession;
$this->session = $session;
$this->request = $request;
$this->mapper = $mapper;
}
protected function getPasswordHash(): string {
return md5('secretpassword');
}
public function isValidToken(): bool {
return $this->getToken() === 'secretToken';
}
protected function isPasswordProtected(): bool {
return false;
}
public function get() {
return new JSONResponse('test');
}
}
[ ‘name’ => ‘PublicAPI#get’, ‘url’ => ‘/api/{token}’, ‘verb’ => ‘GET’ ],
But when i call this route with Postman i have this message
Did someone know how to use properly this types of controllers ?