This commit is contained in:
2024-11-02 20:16:52 +01:00
parent 51a9b9dfd6
commit 571efe1ad9
5 changed files with 45 additions and 10 deletions

View File

@ -11,8 +11,27 @@ class HomeController extends AbstractController
{
public function home()
{
$em = $this->getDoctrine()->getManager();
$items=null;
if($this->getParameter("appNinegateactivate")) {
// Entete
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only'=>'items'];
$query = [];
$url=$this->getParameter("appNinegateurl");
// Paramétrage unirest
\Unirest\Request::verifyPeer(false);
\Unirest\Request::verifyHost(false);
\Unirest\Request::timeout(5);
try {
$response = \Unirest\Request::get($url.'/rest/user/'.($this->getUser()?$this->getUser()->getUsername():"nononononouser"),$headers);
$items=$response->body->items;
}
catch (\Exception $e) {
}
}
dump($items);
$em = $this->getDoctrine()->getManager();
$users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]);
$illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]);
$links = $em->getRepository("App:Link")->findBy(["user"=>null]);
@ -25,7 +44,8 @@ class HomeController extends AbstractController
"users" => $users,
"illustrations" => $illustrations,
"links" => $links,
"webzines" => $webzines
"webzines" => $webzines,
"items" => $items,
]);
}

View File

@ -168,7 +168,7 @@ class SecurityController extends AbstractController
private function updateNinegate($user) {
if($this->getParameter("appNinegateactivate") && $this->getParameter("appNinegatemasteridentity")=="SQL") {
// Entete
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")];
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only' => 'user'];
$query = [];
$url=$this->getParameter("appNinegateurl");
// Paramétrage unirest
@ -177,7 +177,7 @@ class SecurityController extends AbstractController
\Unirest\Request::verifyHost(false);
\Unirest\Request::timeout(5);
try {
$response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers,["only"=>"user"]);
$response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers);
$em = $this->getDoctrine()->getManager();

View File

@ -259,14 +259,14 @@ class UserController extends AbstractController
private function updateNinegate($user) {
if($this->getParameter("appNinegateactivate") && $this->getParameter("appNinegatemasteridentity")=="SQL") {
// Entete
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")];
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret"), 'only' => 'user'];
$query = [];
$url=$this->getParameter("appNinegateurl");
\Unirest\Request::verifyPeer(false);
\Unirest\Request::verifyHost(false);
\Unirest\Request::timeout(5);
try {
$response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers,["only"=>"user"]);
$response = \Unirest\Request::get($url.'/rest/user/'.$user->getUsername(),$headers);
$em = $this->getDoctrine()->getManager();
if(property_exists($response->body->user,'lastname')) $user->setLastname($response->body->user->lastname);