summaryrefslogtreecommitdiff
path: root/app/controllers/indexController.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 19:06:32 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 19:06:32 +0200
commit3ff51a59ba97f3ef1df3c26df16d9a3ab5789843 (patch)
tree89de7b553f5b8240ad0d9f766800973f9845a121 /app/controllers/indexController.php
parent48a1aa7d52e712d5f64a33a003b31f23a00b99f5 (diff)
Ajout fonctionnalité connexion avec Persona (à améliorer sans doute)
Diffstat (limited to 'app/controllers/indexController.php')
-rwxr-xr-xapp/controllers/indexController.php39
1 files changed, 39 insertions, 0 deletions
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');
+ }
}