svg
This commit is contained in:
parent
edea0d279c
commit
475b5c8412
15
.env
15
.env
|
@ -5,6 +5,7 @@
|
||||||
APP_ENV=dev
|
APP_ENV=dev
|
||||||
APP_SECRET=changeme
|
APP_SECRET=changeme
|
||||||
INITPWDADMIN=changeme
|
INITPWDADMIN=changeme
|
||||||
|
PROTOCOLE=http
|
||||||
|
|
||||||
# Webpack
|
# Webpack
|
||||||
APP_PUBLIC_PATH=/ninefolio/build
|
APP_PUBLIC_PATH=/ninefolio/build
|
||||||
|
@ -17,6 +18,20 @@ APP_ALIAS=ninefolio
|
||||||
APP_NAME="NINEFOLIO"
|
APP_NAME="NINEFOLIO"
|
||||||
APP_CRON=1
|
APP_CRON=1
|
||||||
|
|
||||||
|
# NINEGATE
|
||||||
|
NINEGATE_ACTIVATE=0
|
||||||
|
NINEGATE_URL=
|
||||||
|
NINEGATE_SECRET=
|
||||||
|
NINEGATE_MASTERIDENTITY=
|
||||||
|
|
||||||
|
# CAS
|
||||||
|
CAS_HOST=
|
||||||
|
CAS_PORT=
|
||||||
|
CAS_PATH=
|
||||||
|
CAS_USERNAME=username
|
||||||
|
CAS_MAIL=email
|
||||||
|
CAS_LASTNAME=lastname
|
||||||
|
CAS_FIRSTNAME=firstname
|
||||||
|
|
||||||
# BDD
|
# BDD
|
||||||
DATABASE_NAME=ninefolio
|
DATABASE_NAME=ninefolio
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"doctrine/annotations": "^1.8",
|
"doctrine/annotations": "^1.8",
|
||||||
"friendsofsymfony/ckeditor-bundle": "^2.2",
|
"friendsofsymfony/ckeditor-bundle": "^2.2",
|
||||||
"friendsofsymfony/rest-bundle": "^3.0",
|
"friendsofsymfony/rest-bundle": "^3.0",
|
||||||
"jasig/phpcas": "^1.3",
|
"jasig/phpcas": "^1.6",
|
||||||
"knplabs/knp-snappy-bundle": "^1.7",
|
"knplabs/knp-snappy-bundle": "^1.7",
|
||||||
"mashape/unirest-php": "^3.0",
|
"mashape/unirest-php": "^3.0",
|
||||||
"nategood/httpful": "^0.3.2",
|
"nategood/httpful": "^0.3.2",
|
||||||
|
|
|
@ -1598,24 +1598,28 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jasig/phpcas",
|
"name": "jasig/phpcas",
|
||||||
"version": "1.3.8",
|
"version": "1.6.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/apereo/phpCAS.git",
|
"url": "https://github.com/apereo/phpCAS.git",
|
||||||
"reference": "40c0769ce05a30c8172b36ceab11124375c8366e"
|
"reference": "c129708154852656aabb13d8606cd5b12dbbabac"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/apereo/phpCAS/zipball/40c0769ce05a30c8172b36ceab11124375c8366e",
|
"url": "https://api.github.com/repos/apereo/phpCAS/zipball/c129708154852656aabb13d8606cd5b12dbbabac",
|
||||||
"reference": "40c0769ce05a30c8172b36ceab11124375c8366e",
|
"reference": "c129708154852656aabb13d8606cd5b12dbbabac",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"php": ">=5.4.0"
|
"ext-dom": "*",
|
||||||
|
"php": ">=7.1.0",
|
||||||
|
"psr/log": "^1.0 || ^2.0 || ^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~3.7.10"
|
"monolog/monolog": "^1.0.0 || ^2.0.0",
|
||||||
|
"phpstan/phpstan": "^1.5",
|
||||||
|
"phpunit/phpunit": ">=7.5"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -1624,6 +1628,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"source/CAS.php"
|
||||||
|
],
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"source/"
|
"source/"
|
||||||
]
|
]
|
||||||
|
@ -1635,11 +1642,16 @@
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Joachim Fritschi",
|
"name": "Joachim Fritschi",
|
||||||
"homepage": "https://wiki.jasig.org/display/~fritschi"
|
"email": "jfritschi@freenet.de",
|
||||||
|
"homepage": "https://github.com/jfritschi"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Adam Franco",
|
"name": "Adam Franco",
|
||||||
"homepage": "https://wiki.jasig.org/display/~adamfranco"
|
"homepage": "https://github.com/adamfranco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Henry Pan",
|
||||||
|
"homepage": "https://github.com/phy25"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Provides a simple API for authenticating users against a CAS server",
|
"description": "Provides a simple API for authenticating users against a CAS server",
|
||||||
|
@ -1649,7 +1661,12 @@
|
||||||
"cas",
|
"cas",
|
||||||
"jasig"
|
"jasig"
|
||||||
],
|
],
|
||||||
"time": "2019-08-18T20:01:55+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/apereo/phpCAS/issues",
|
||||||
|
"source": "https://github.com/apereo/phpCAS/tree/1.6.1"
|
||||||
|
},
|
||||||
|
"abandoned": "apereo/phpcas",
|
||||||
|
"time": "2023-02-19T19:52:35+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "knplabs/knp-snappy",
|
"name": "knplabs/knp-snappy",
|
||||||
|
|
|
@ -7,6 +7,7 @@ parameters:
|
||||||
appEnv: '%env(resolve:APP_ENV)%'
|
appEnv: '%env(resolve:APP_ENV)%'
|
||||||
appSecret: '%env(resolve:APP_SECRET)%'
|
appSecret: '%env(resolve:APP_SECRET)%'
|
||||||
appInitpwdadmin: '%env(resolve:INITPWDADMIN)%'
|
appInitpwdadmin: '%env(resolve:INITPWDADMIN)%'
|
||||||
|
protocole: '%env(resolve:PROTOCOLE)%'
|
||||||
|
|
||||||
appWeburl: '%env(resolve:APP_WEBURL)%'
|
appWeburl: '%env(resolve:APP_WEBURL)%'
|
||||||
appAuth: '%env(resolve:APP_AUTH)%'
|
appAuth: '%env(resolve:APP_AUTH)%'
|
||||||
|
@ -14,6 +15,19 @@ parameters:
|
||||||
appName: '%env(resolve:APP_NAME)%'
|
appName: '%env(resolve:APP_NAME)%'
|
||||||
appCron: '%env(resolve:APP_CRON)%'
|
appCron: '%env(resolve:APP_CRON)%'
|
||||||
|
|
||||||
|
appNinegateactivate: '%env(resolve:NINEGATE_ACTIVATE)%'
|
||||||
|
appNinegateurl: '%env(resolve:NINEGATE_URL)%'
|
||||||
|
appNinegatesecret: '%env(resolve:NINEGATE_SECRET)%'
|
||||||
|
appNinegatemasteridentity: '%env(resolve:NINEGATE_MASTERIDENTITY)%'
|
||||||
|
|
||||||
|
casHost: '%env(resolve:CAS_HOST)%'
|
||||||
|
casPort: '%env(resolve:CAS_PORT)%'
|
||||||
|
casPath: '%env(resolve:CAS_PATH)%'
|
||||||
|
casUsername: '%env(resolve:CAS_USERNAME)%'
|
||||||
|
casMail: '%env(resolve:CAS_MAIL)%'
|
||||||
|
casLastname: '%env(resolve:CAS_LASTNAME)%'
|
||||||
|
casFirstname: '%env(resolve:CAS_FIRSTNAME)%'
|
||||||
|
|
||||||
databaseName: '%env(resolve:DATABASE_NAME)%'
|
databaseName: '%env(resolve:DATABASE_NAME)%'
|
||||||
databaseUser: '%env(resolve:DATABASE_USER)%'
|
databaseUser: '%env(resolve:DATABASE_USER)%'
|
||||||
databasePassword: '%env(resolve:DATABASE_PASSWORD)%'
|
databasePassword: '%env(resolve:DATABASE_PASSWORD)%'
|
||||||
|
|
|
@ -373,7 +373,7 @@ th.dt-center, td.dt-center { text-align: center; }
|
||||||
.grid-item-size-8 { width: 80%; margin-bottom: 0%;float:left;}
|
.grid-item-size-8 { width: 80%; margin-bottom: 0%;float:left;}
|
||||||
.grid-item-size-9 { width: 90%; margin-bottom: 0%;float:left;}
|
.grid-item-size-9 { width: 90%; margin-bottom: 0%;float:left;}
|
||||||
.grid-item-full { width: 100%; margin-bottom: 0%; font-size:20px;float:left; }
|
.grid-item-full { width: 100%; margin-bottom: 0%; font-size:20px;float:left; }
|
||||||
.grid-item-full h1 {margin: 0; border:none; padding: 20px 0px 0px 10px; }
|
.grid-item-full h1 {margin: 0; border:none; padding: 20px 0px 0px 0px; }
|
||||||
.gutter-sizer { width: 0%;float:left; }
|
.gutter-sizer { width: 0%;float:left; }
|
||||||
.member{display:flex; flex-direction: column; align-items: center; background-color: var(--colorbgbodydarkdarker); border-radius:10px; padding:10px;}
|
.member{display:flex; flex-direction: column; align-items: center; background-color: var(--colorbgbodydarkdarker); border-radius:10px; padding:10px;}
|
||||||
.member img{border-radius:100%;width:60px; height: 60px;}
|
.member img{border-radius:100%;width:60px; height: 60px;}
|
||||||
|
|
|
@ -13,6 +13,20 @@ class HomeController extends AbstractController
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
if($this->getUser()) {
|
||||||
|
// Entete
|
||||||
|
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")];
|
||||||
|
$query = [];
|
||||||
|
$url=$this->getParameter("appNinegateurl");
|
||||||
|
// Paramétrage unirest
|
||||||
|
|
||||||
|
\Unirest\Request::verifyPeer(false);
|
||||||
|
\Unirest\Request::verifyHost(false);
|
||||||
|
\Unirest\Request::timeout(5);
|
||||||
|
//dd($url.'/rest/user/'.$this->getUser()->getUsername());
|
||||||
|
$response = \Unirest\Request::get($url.'/rest/user/'.$this->getUser()->getUsername(),$headers,["only"=>"user,groups"]);
|
||||||
|
}
|
||||||
|
|
||||||
$users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]);
|
$users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]);
|
||||||
$illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]);
|
$illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]);
|
||||||
$links = $em->getRepository("App:Link")->findBy(["user"=>null]);
|
$links = $em->getRepository("App:Link")->findBy(["user"=>null]);
|
||||||
|
|
|
@ -44,9 +44,10 @@ class SecurityController extends AbstractController
|
||||||
$redirect = $this->get('session')->get("_security.main.target_path");
|
$redirect = $this->get('session')->get("_security.main.target_path");
|
||||||
|
|
||||||
// Init Client CAS
|
// Init Client CAS
|
||||||
$alias=$this->getParameter('appAlias');
|
$url=$this->getHost($request);
|
||||||
\phpCAS::setDebug('/var/www/html/'.$alias.'/var/log/cas.log');
|
$url=str_replace("http://",$this->getParameter("protocole")."://",$url);
|
||||||
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), false);
|
$url=str_replace("https://",$this->getParameter("protocole")."://",$url);
|
||||||
|
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), $url, false);
|
||||||
\phpCAS::setNoCasServerValidation();
|
\phpCAS::setNoCasServerValidation();
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ class SecurityController extends AbstractController
|
||||||
if(isset($attributes[$this->getParameter('casUsername')]))
|
if(isset($attributes[$this->getParameter('casUsername')]))
|
||||||
$username = $attributes[$this->getParameter('casUsername')];
|
$username = $attributes[$this->getParameter('casUsername')];
|
||||||
|
|
||||||
if(isset($attributes[$this->getParameter('casEmail')]))
|
if(isset($attributes[$this->getParameter('casMail')]))
|
||||||
$email = $attributes[$this->getParameter('casEmail')];
|
$email = $attributes[$this->getParameter('casMail')];
|
||||||
|
|
||||||
if(isset($attributes[$this->getParameter('casLastname')]))
|
if(isset($attributes[$this->getParameter('casLastname')]))
|
||||||
$lastname = $attributes[$this->getParameter('casLastname')];
|
$lastname = $attributes[$this->getParameter('casLastname')];
|
||||||
|
@ -100,6 +101,8 @@ class SecurityController extends AbstractController
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->updateNinegate($user);
|
||||||
|
|
||||||
// Sauvegarde des attributes en session
|
// Sauvegarde des attributes en session
|
||||||
$this->get('session')->set('attributes', $attributes);
|
$this->get('session')->set('attributes', $attributes);
|
||||||
|
|
||||||
|
@ -120,44 +123,80 @@ class SecurityController extends AbstractController
|
||||||
return $this->redirect($this->generateUrl('app_home'));
|
return $this->redirect($this->generateUrl('app_home'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request) {
|
||||||
|
|
||||||
public function logout() {
|
|
||||||
$auth_mode=$this->getParameter("appAuth");
|
$auth_mode=$this->getParameter("appAuth");
|
||||||
switch($auth_mode) {
|
switch($auth_mode) {
|
||||||
case "MYSQL":
|
case "MYSQL":
|
||||||
return $this->logoutMYSQL();
|
return $this->logoutMYSQL($request);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "CAS":
|
case "CAS":
|
||||||
return $this->logoutCAS();
|
return $this->logoutCAS($request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logoutMYSQL() {
|
public function logoutMYSQL(Request $request) {
|
||||||
$this->get('security.token_storage')->setToken(null);
|
$this->get('security.token_storage')->setToken(null);
|
||||||
$this->get('session')->invalidate();
|
$this->get('session')->invalidate();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl("app_home"));
|
return $this->redirect($this->generateUrl("app_home"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logoutcas() {
|
public function logoutcas(Request $request) {
|
||||||
$this->get('security.token_storage')->setToken(null);
|
|
||||||
$this->get('session')->invalidate();
|
|
||||||
|
|
||||||
// Init Client CAS
|
// Init Client CAS
|
||||||
$alias=$this->getParameter('appAlias');
|
$url=$this->getHost($request);
|
||||||
\phpCAS::setDebug('/var/www/html/'.$alias.'/var/log/cas.log');
|
$url=str_replace("http://",$this->getParameter("protocole")."://",$url);
|
||||||
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), false);
|
$url=str_replace("https://",$this->getParameter("protocole")."://",$url);
|
||||||
|
\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('casHost'), intval($this->getParameter('casPort')), is_null($this->getParameter('casPath')) ? '' : $this->getParameter('casPath'), $url, false);
|
||||||
\phpCAS::setNoCasServerValidation();
|
\phpCAS::setNoCasServerValidation();
|
||||||
|
|
||||||
|
|
||||||
// Logout
|
// Logout
|
||||||
$url=$this->generateUrl('app_home', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
$url = $this->generateUrl('app_home', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
\phpCAS::logout(array("service"=>$url));
|
$url=str_replace("http://",$this->getParameter("protocole")."://",$url);
|
||||||
|
$url=str_replace("https://",$this->getParameter("protocole")."://",$url);
|
||||||
|
\phpCAS::logout(['service' => $url]);
|
||||||
|
|
||||||
|
$this->tokenstorage->setToken(null);
|
||||||
|
$request->getSession()->invalidate();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function updateNinegate($user) {
|
||||||
|
if($this->getParameter("appNinegateactivate") && $this->getParameter("appNinegatemasteridentity")=="SQL") {
|
||||||
|
// Entete
|
||||||
|
$headers = ['Accept' => 'application/json', 'key' => $this->getParameter("appNinegatesecret")];
|
||||||
|
$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/'.$user->getUsername(),$headers,["only"=>"user"]);
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
if(property_exists($response->body->user,'lastname')) $user->setLastname($response->body->user->lastname);
|
||||||
|
if(property_exists($response->body->user,'firstname')) $user->setFirstname($response->body->user->firstname);
|
||||||
|
if(property_exists($response->body->user,'usualname')) $user->setPseudo($response->body->user->usualname);
|
||||||
|
if(property_exists($response->body->user,'email')) $user->setEmail($response->body->user->email);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getHost($request) {
|
||||||
|
$host = $request->getHost();
|
||||||
|
$protocol = $request->getScheme();
|
||||||
|
$port = $request->getPort();
|
||||||
|
return $protocol."://".$host.($port!=80&&$port!=443?":".$port:"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ class UserController extends AbstractController
|
||||||
$this->data."s" => $datas,
|
$this->data."s" => $datas,
|
||||||
"useheader" => true,
|
"useheader" => true,
|
||||||
"usesidebar" => true,
|
"usesidebar" => true,
|
||||||
]);
|
'appNinegateactivate' => $this->getParameter("appNinegateactivate"),
|
||||||
|
'appNinegateurl' => $this->getParameter("appNinegateurl"), ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit(Request $request)
|
public function submit(Request $request)
|
||||||
|
@ -36,6 +37,9 @@ class UserController extends AbstractController
|
||||||
$data = new Entity();
|
$data = new Entity();
|
||||||
$data->setAvatar("noavatar.png");
|
$data->setAvatar("noavatar.png");
|
||||||
|
|
||||||
|
if($this->getParameter("appNinegateactivate")) return $this->redirectToRoute($this->route);
|
||||||
|
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||||
|
|
||||||
|
@ -61,7 +65,9 @@ class UserController extends AbstractController
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'submit',
|
'mode' => 'submit',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
|
'appNinegateactivate' => $this->getParameter("appNinegateactivate"),
|
||||||
|
'appNinegateurl' => $this->getParameter("appNinegateurl"),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +78,11 @@ class UserController extends AbstractController
|
||||||
$data=$em->getRepository($this->entity)->find($id);
|
$data=$em->getRepository($this->entity)->find($id);
|
||||||
$oldpassword=$data->getPassword();
|
$oldpassword=$data->getPassword();
|
||||||
|
|
||||||
|
// Récupération Nineage
|
||||||
|
$data=$this->updateNinegate($data);
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","appAuth"=>$this->getParameter("appAuth")));
|
$form = $this->createForm(Form::class,$data,array("mode"=>"update","appNinegateactivate"=>$this->getParameter("appNinegateactivate")));
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
// Récupération des data du formulaire
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
@ -103,7 +112,9 @@ class UserController extends AbstractController
|
||||||
'usesidebar' => true,
|
'usesidebar' => true,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'update',
|
'mode' => 'update',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
|
'appNinegateactivate' => $this->getParameter("appNinegateactivate"),
|
||||||
|
'appNinegateurl' => $this->getParameter("appNinegateurl"),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +146,11 @@ class UserController extends AbstractController
|
||||||
$data=$this->getUser();
|
$data=$this->getUser();
|
||||||
$oldpassword=$data->getPassword();
|
$oldpassword=$data->getPassword();
|
||||||
|
|
||||||
|
// Récupération Nineage
|
||||||
|
$data=$this->updateNinegate($data);
|
||||||
|
|
||||||
// Création du formulaire
|
// Création du formulaire
|
||||||
$form = $this->createForm(Form::class,$data,array("mode"=>"profil","appAuth"=>$this->getParameter("appAuth")));
|
$form = $this->createForm(Form::class,$data,array("mode"=>"profil","appNinegateactivate"=>$this->getParameter("appNinegateactivate")));
|
||||||
|
|
||||||
// Récupération des data du formulaire
|
// Récupération des data du formulaire
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
@ -166,7 +180,9 @@ class UserController extends AbstractController
|
||||||
'usesidebar' => false,
|
'usesidebar' => false,
|
||||||
$this->data => $data,
|
$this->data => $data,
|
||||||
'mode' => 'profil',
|
'mode' => 'profil',
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
|
'appNinegateactivate' => $this->getParameter("appNinegateactivate"),
|
||||||
|
'appNinegateurl' => $this->getParameter("appNinegateurl"),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,4 +255,29 @@ 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")];
|
||||||
|
$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"]);
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
if(property_exists($response->body->user,'lastname')) $user->setLastname($response->body->user->lastname);
|
||||||
|
if(property_exists($response->body->user,'firstname')) $user->setFirstname($response->body->user->firstname);
|
||||||
|
if(property_exists($response->body->user,'usualname')) $user->setPseudo($response->body->user->usualname);
|
||||||
|
if(property_exists($response->body->user,'email')) $user->setEmail($response->body->user->email);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,8 +395,8 @@ class User implements UserInterface, \Serializable
|
||||||
|
|
||||||
public function setPseudo(?string $pseudo): self
|
public function setPseudo(?string $pseudo): self
|
||||||
{
|
{
|
||||||
$this->pseudo = $pseudo;
|
$this->pseudo = $pseudo?$pseudo:$this->username;
|
||||||
$pseudo=strtolower($pseudo);
|
$pseudo=strtolower($this->pseudo);
|
||||||
if($pseudo=="admin"||$pseudo=="user"||$pseudo=="feed"||$pseudo=="_uploader") $pseudo.="home";
|
if($pseudo=="admin"||$pseudo=="user"||$pseudo=="feed"||$pseudo=="_uploader") $pseudo.="home";
|
||||||
$this->slug = $pseudo;
|
$this->slug = $pseudo;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -45,6 +45,7 @@ class UserType extends AbstractType
|
||||||
$builder->add('pseudo',
|
$builder->add('pseudo',
|
||||||
TextType::class, [
|
TextType::class, [
|
||||||
"label" =>"Pseudo",
|
"label" =>"Pseudo",
|
||||||
|
"disabled" => $options["appNinegateactivate"],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ class UserType extends AbstractType
|
||||||
$builder->add('lastname',
|
$builder->add('lastname',
|
||||||
TextType::class, [
|
TextType::class, [
|
||||||
"label" =>"Nom",
|
"label" =>"Nom",
|
||||||
|
"disabled" => $options["appNinegateactivate"],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -93,12 +95,14 @@ class UserType extends AbstractType
|
||||||
TextType::class, [
|
TextType::class, [
|
||||||
"label" =>"Prénom",
|
"label" =>"Prénom",
|
||||||
"required" => false,
|
"required" => false,
|
||||||
|
"disabled" => $options["appNinegateactivate"],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->add('email',
|
$builder->add('email',
|
||||||
EmailType::class, [
|
EmailType::class, [
|
||||||
"label" =>"Email",
|
"label" =>"Email",
|
||||||
|
"disabled" => $options["appNinegateactivate"],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -106,6 +110,7 @@ class UserType extends AbstractType
|
||||||
RepeatedType::class, [
|
RepeatedType::class, [
|
||||||
"type" => PasswordType::class,
|
"type" => PasswordType::class,
|
||||||
"required" => ($options["mode"]=="submit"?true:false),
|
"required" => ($options["mode"]=="submit"?true:false),
|
||||||
|
"disabled" => $options["appNinegateactivate"],
|
||||||
"options" => array("always_empty" => true),
|
"options" => array("always_empty" => true),
|
||||||
"first_options" => array("label" => "Mot de Passe","attr" => array("class" => "form-control", "style" => "margin-bottom:15px", "autocomplete" => "new-password")),
|
"first_options" => array("label" => "Mot de Passe","attr" => array("class" => "form-control", "style" => "margin-bottom:15px", "autocomplete" => "new-password")),
|
||||||
"second_options" => array('label' => 'Confirmer Mot de Passe',"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"))
|
"second_options" => array('label' => 'Confirmer Mot de Passe',"attr" => array("class" => "form-control", "style" => "margin-bottom:15px"))
|
||||||
|
@ -118,7 +123,7 @@ class UserType extends AbstractType
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'App\Entity\User',
|
'data_class' => 'App\Entity\User',
|
||||||
'mode' => 'string',
|
'mode' => 'string',
|
||||||
'appAuth' => 'string',
|
'appNinegateactivate' => 'boolean',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{{ form_widget(form.submit) }}
|
{{ form_widget(form.submit) }}
|
||||||
|
|
||||||
{% if mode=="profil" %}
|
{% if mode=="profil" %}
|
||||||
<a class="btn btn-secondary" href={{ path('app_home_user',{userpseudo:user.pseudo}) }}>Annuler</a>
|
<a class="btn btn-secondary" href={{ path('app_home_user',{userpseudo:user.slug}) }}>Annuler</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="btn btn-secondary" href={{ path('app_user') }}>Annuler</a>
|
<a class="btn btn-secondary" href={{ path('app_user') }}>Annuler</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -75,6 +75,16 @@
|
||||||
{{ form_row(form.firstname) }}
|
{{ form_row(form.firstname) }}
|
||||||
{{ form_row(form.pseudo) }}
|
{{ form_row(form.pseudo) }}
|
||||||
{{ form_row(form.email) }}
|
{{ form_row(form.email) }}
|
||||||
|
|
||||||
|
{% if mode!="submit" %}
|
||||||
|
{% if appNinegateactivate %}
|
||||||
|
{% if mode=="profil" %}
|
||||||
|
<a class="btn btn-info" style="width:100%" href="{{appNinegateurl}}/user?redirect={{app.request.uri}}">Modfier</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="btn btn-info" style="width:100%" href="{{appNinegateurl}}/config/user/update/{{user.username}}?redirect={{app.request.uri}}">Modifier</a>
|
||||||
|
{% endif %}
|
||||||
|
{%endif%}
|
||||||
|
{%endif%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
UTILISATEURS
|
UTILISATEURS
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
{% if appNinegateactivate %}
|
||||||
|
<p><a class="btn btn-success" href={{ appNinegateurl }}/config/user/submit?redirect={{app.request.uri}}>Ajouter</a></p>
|
||||||
|
{% else %}
|
||||||
<p><a class="btn btn-success" href={{ path('app_user_submit') }}>Ajouter</a></p>
|
<p><a class="btn btn-success" href={{ path('app_user_submit') }}>Ajouter</a></p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
|
Loading…
Reference in New Issue