118 lines
4.0 KiB
PHP
118 lines
4.0 KiB
PHP
|
<?php
|
||
|
class AuthController extends Zend_Controller_Action
|
||
|
{
|
||
|
protected $partnerConfig = array(
|
||
|
'inextenso' => array(
|
||
|
'clientId' => 0,
|
||
|
'serviceCode' => 'SSO',
|
||
|
'authType' => 'userSSO',
|
||
|
'login' => 'MAIL',
|
||
|
'token' => 'token',
|
||
|
)
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* Point d'entrée pour les connexions partenaires.
|
||
|
* L'utilisateur s'identifie sur son portail habituel.
|
||
|
*/
|
||
|
public function indexAction()
|
||
|
{
|
||
|
//Désactiver le layout
|
||
|
$this->_helper->layout()->disableLayout();
|
||
|
|
||
|
$request = $this->getRequest();
|
||
|
|
||
|
/**
|
||
|
* Get partner name - see route in bootstrap
|
||
|
*/
|
||
|
$partner = $request->getParam('partner');
|
||
|
if ( array_key_exists($partner, $partnerConfig) ) {
|
||
|
$config = $partnerConfig[$partner];
|
||
|
$params = $request->getParams();
|
||
|
$objectParams = array();
|
||
|
foreach ($params as $label => $value) {
|
||
|
$object = new stdClass();
|
||
|
$object->label = $label;
|
||
|
$object->value = $value;
|
||
|
$objectParams[] = $object;
|
||
|
}
|
||
|
$login = $params[$partnerConfig['login']];
|
||
|
$part = strstr($login, '@', true);
|
||
|
if ($part !== false) {
|
||
|
$login = $part;
|
||
|
}
|
||
|
$token = $params[$partnerConfig['token']];
|
||
|
$ws = new Scores_Ws_Client('gestion', '0.4');
|
||
|
try {
|
||
|
$hash = $ws->ssoAuthenticate($config['clientId'], $login, $token, $objectParams);
|
||
|
//Utilisateur inexistant
|
||
|
if ($hash === false ) {
|
||
|
$this->view->NoUser = true;
|
||
|
//Set form value
|
||
|
$this->view->FormIdentifiant = $login;
|
||
|
$this->view->FormCourriel = $request->getParam('MAIL');
|
||
|
$this->view->FormSiret = $request->getParam('SIRET');
|
||
|
$this->view->FormNom = $request->getParam('LASTNAME');
|
||
|
$this->view->FormPrenom = $request->getParam('FIRSTNAME');
|
||
|
}
|
||
|
//Redirection
|
||
|
else {
|
||
|
$auth = Zend_Auth::getInstance();
|
||
|
//First set partial identity
|
||
|
$identity = new stdClass();
|
||
|
$identity->username = $login;
|
||
|
$identity->password = $hash;
|
||
|
$auth->getStorage()->write($identity);
|
||
|
$adressIp = $_SERVER['REMOTE_ADDR'];
|
||
|
$ws = new Scores_Ws_Client('gestion', '0.3');
|
||
|
$InfosLogin = $ws->getInfosLogin($login, $adressIp);
|
||
|
if ( is_string($InfosLogin) || $InfosLogin->error->errnum != 0 ) {
|
||
|
$this->view->Error = true;
|
||
|
} else {
|
||
|
$identity = $user->updateProfil($InfosLogin);
|
||
|
$auth->getStorage()->write($identity);
|
||
|
//Redirect
|
||
|
$this->redirect('/');
|
||
|
}
|
||
|
}
|
||
|
} catch ( Exception $e ) {
|
||
|
switch ( $e->getCode() ) {
|
||
|
case 'MSG':
|
||
|
$this->view->Message = $e->getMessage();
|
||
|
break;
|
||
|
default:
|
||
|
$this->view->Error = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
$this->view->Message = "Erreur dans les paramètres.";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function userssocreateAction()
|
||
|
{
|
||
|
$this->_helper->layout()->disableLayout();
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Lien de validation depuis email
|
||
|
* Paramètres
|
||
|
* - login ou email
|
||
|
* - key
|
||
|
* L'action renvoi sur un affichage spécifique suivant le type de client
|
||
|
*/
|
||
|
public function validateAction()
|
||
|
{
|
||
|
$request = $this->getRequest();
|
||
|
|
||
|
//Validation en erreur
|
||
|
|
||
|
//Validation invalide
|
||
|
|
||
|
//Validation Ok => Comment afficher les particularités
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|