aboutsummaryrefslogtreecommitdiff
path: root/app/layout
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/layout
parent48a1aa7d52e712d5f64a33a003b31f23a00b99f5 (diff)
Ajout fonctionnalité connexion avec Persona (à améliorer sans doute)
Diffstat (limited to 'app/layout')
-rw-r--r--app/layout/aside.phtml16
-rw-r--r--app/layout/layout.phtml3
-rw-r--r--app/layout/persona.phtml73
3 files changed, 90 insertions, 2 deletions
diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml
index f88f6cc0f..50af6c3b2 100644
--- a/app/layout/aside.phtml
+++ b/app/layout/aside.phtml
@@ -19,16 +19,28 @@
</ul>
<?php } ?>
</li>
+ <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
<li <?php echo Request::controllerName () == 'configure' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Configurer</a>
</li>
+ <?php } ?>
<li>
<a href="<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize')); ?>">Mettre les flux à jour</a>
</li>
+ <?php if (login_is_conf ($this->conf)) { ?>
+ <li>
+ <?php if (!is_logged ()) { ?>
+ <a id="signin" href="#">Connexion</a>
+ <?php } else { ?>
+ <a id="signout" href="#">Déconnexion</a>
+ <?php } ?>
+ </li>
+ <?php } ?>
</ul>
</div>
-<?php if (Request::controllerName () == 'configure') { ?>
+<?php if (Request::controllerName () == 'configure' &&
+ (!login_is_conf ($this->conf) || is_logged ())) { ?>
<div class="aside">
<ul id="menu">
<li><h2>Configuration</h2></li>
@@ -39,7 +51,7 @@
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'categorize')); ?>">Catégories</a>
</li>
<li <?php echo Request::actionName () == 'display' ? 'class="active"' : ''; ?>>
- <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'display')); ?>">Affichage</a>
+ <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'display')); ?>">Général et affichage</a>
</li>
<li <?php echo Request::actionName () == 'importExport' ? 'class="active"' : ''; ?>>
<a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport')); ?>">Import / Export OPML</a>
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 1436db9e6..e73f14ba1 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -14,5 +14,8 @@
<?php $this->render (); ?>
</div>
</div>
+
+<?php $this->partial ('persona'); ?>
+
</body>
</html>
diff --git a/app/layout/persona.phtml b/app/layout/persona.phtml
new file mode 100644
index 000000000..8db8d5167
--- /dev/null
+++ b/app/layout/persona.phtml
@@ -0,0 +1,73 @@
+<?php if (login_is_conf ($this->conf)) { ?>
+<?php
+ $mail = Session::param ('mail', 'null');
+ if ($mail != 'null') {
+ $mail = '\'' . $mail . '\'';
+ }
+?>
+
+<script type="text/javascript">
+url = "<?php echo Url::display (); ?>"
+login_url = "<?php echo Url::display (array ('a' => 'login')); ?>";
+logout_url = "<?php echo Url::display (array ('a' => 'logout')); ?>";
+currentUser = <?php echo $mail; ?>;
+
+var signinLink = $('a#signin');
+if (signinLink) {
+ signinLink.click(function() {
+ navigator.id.request();
+ return false;
+ });
+};
+
+var signoutLink = $('a#signout');
+if (signoutLink) {
+ signoutLink.click(function() {
+ navigator.id.logout();
+ return false;
+ });
+};
+
+navigator.id.watch({
+ loggedInUser: currentUser,
+ onlogin: function(assertion) {
+ // A user has logged in! Here you need to:
+ // 1. Send the assertion to your backend for verification and to create a session.
+ // 2. Update your UI.
+ $.ajax ({
+ type: 'POST',
+ url: login_url,
+ data: {assertion: assertion},
+ success: function(res, status, xhr) {
+ var res_obj = jQuery.parseJSON(res);
+
+ if (res_obj.status == 'failure') {
+ //alert (res_obj.reason);
+ } else if (res_obj.status == 'okay') {
+ location.href = url;
+ }
+ },
+ error: function(res, status, xhr) {
+ alert("login failure : " + res);
+ }
+ });
+ },
+ onlogout: function() {
+ // A user has logged out! Here you need to:
+ // Tear down the user's session by redirecting the user or making a call to your backend.
+ // Also, make sure loggedInUser will get set to null on the next page load.
+ // (That's a literal JavaScript null. Not false, 0, or undefined. null.)
+ $.ajax ({
+ type: 'POST',
+ url: logout_url,
+ success: function(res, status, xhr) {
+ location.href = url;
+ },
+ error: function(res, status, xhr) {
+ //alert("logout failure" + res);
+ }
+ });
+ }
+});
+</script>
+<?php } ?>