From 3ff51a59ba97f3ef1df3c26df16d9a3ab5789843 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 25 Oct 2012 19:06:32 +0200 Subject: Ajout fonctionnalité connexion avec Persona (à améliorer sans doute) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/indexController.php | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'app/controllers/indexController.php') diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index e7e3797ef..6db825ea6 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -2,6 +2,10 @@ class indexController extends ActionController { public function indexAction () { + View::appendScript (Url::display ('/scripts/smoothscroll.js')); + View::appendScript (Url::display ('/scripts/shortcut.js')); + View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); + $entryDAO = new EntryDAO (); $catDAO = new CategoryDAO (); @@ -42,4 +46,39 @@ class indexController extends ActionController { Request::forward (array (), true); } + + public function loginAction () { + $this->view->_useLayout (false); + + $url = 'https://verifier.login.persona.org/verify'; + $assert = Request::param ('assertion'); + $params = 'assertion=' . $assert . '&audience=' . + urlencode (Url::display () . ':80'); + $ch = curl_init (); + $options = array ( + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => TRUE, + CURLOPT_POST => 2, + CURLOPT_POSTFIELDS => $params + ); + curl_setopt_array ($ch, $options); + $result = curl_exec ($ch); + curl_close ($ch); + + $res = json_decode ($result, true); + if ($res['status'] == 'okay' && $res['email'] == $this->view->conf->mailLogin ()) { + Session::_param ('mail', $res['email']); + } else { + $res = array (); + $res['status'] = 'failure'; + $res['reason'] = 'L\'identifiant est invalide'; + } + + $this->view->res = json_encode ($res); + } + + public function logoutAction () { + $this->view->_useLayout (false); + Session::_param ('mail'); + } } -- cgit v1.2.3