diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-13 05:17:58 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-13 05:17:58 +0000 |
commit | 6d7130bffc2e124c9eed9fca3f772dcbd620fd12 (patch) | |
tree | d0458157c3105a163d5a876516556ebf1da35652 | |
parent | f62719ba61e755cf40b178f6a3c940833df650e1 (diff) |
Progress is being made... you can now logout
-rw-r--r-- | modules/user/controllers/login.php | 13 | ||||
-rw-r--r-- | modules/user/controllers/logout.php | 21 | ||||
-rw-r--r-- | themes/default/js/login.js | 20 | ||||
-rw-r--r-- | themes/default/views/header.html.php | 2 |
4 files changed, 30 insertions, 26 deletions
diff --git a/modules/user/controllers/login.php b/modules/user/controllers/login.php index 991fa73b..2debf6d3 100644 --- a/modules/user/controllers/login.php +++ b/modules/user/controllers/login.php @@ -19,7 +19,6 @@ */ class Login_Controller extends Controller { public function index() { - Kohana::log("debug", "Login_Controller/index"); $form = new Forge(); $form->input("username")->rules("required|length[4,32]"); $form->password("password")->rules("required|length[5,40]"); @@ -28,9 +27,6 @@ class Login_Controller extends Controller { } public function process() { - Kohana::log("debug", "Login_Controller/process"); - - Kohana::log("debug", print_r($_POST, true)); $form = new Forge("login.html", true); $form->input("username")->rules("required|length[4,32]"); $form->password("password")->rules("required|length[5,40]"); @@ -56,4 +52,13 @@ class Login_Controller extends Controller { print json_encode($response); } + + public function logout() { + try { + Session::instance()->destroy(); + } catch (Exception $e) { + Kohana::log("error", $e); + } + print json_encode(array("logout" => true)); + } }
\ No newline at end of file diff --git a/modules/user/controllers/logout.php b/modules/user/controllers/logout.php deleted file mode 100644 index c26c6776..00000000 --- a/modules/user/controllers/logout.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access."); -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2008 Bharat Mediratta - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ -class Logout_Controller extends Controller { -}
\ No newline at end of file diff --git a/themes/default/js/login.js b/themes/default/js/login.js index e08897df..5acc711f 100644 --- a/themes/default/js/login.js +++ b/themes/default/js/login.js @@ -3,6 +3,10 @@ $(document).ready(function() { process_login(); return false; }); + $("#gLogoutLink").click(function() { + process_logout(); + return false; + }); }); function show_login() { @@ -46,4 +50,20 @@ function process_login() { } } }); +} + +function process_logout() { + $.ajax({ + url: $("#gLogoutLink").attr("href"), + type: "GET", + dataType: "json", + error: function(XMLHttpRequest, textStatus, errorThrown) { + alert("textStatus: " + textStatus + "\nerrorThrown: " + errorThrown); + }, + success: function(data, textStatus) { + if (data.logout) { + window.location.reload(); + } + } + }); }
\ No newline at end of file diff --git a/themes/default/views/header.html.php b/themes/default/views/header.html.php index e427838b..f212bdb6 100644 --- a/themes/default/views/header.html.php +++ b/themes/default/views/header.html.php @@ -5,7 +5,7 @@ <div id="gLoginMenu"> <? if ($user): ?> <a href="<?= url::site("user/update")?>"><?= _("Modify Profile") ?></a> | - <a href="<?= url::site("logout")?>"><?= _("Logout") ?></a> + <a href="<?= url::site("login/logout")?>" id="gLogoutLink"><?= _("Logout") ?></a> <? else: ?> <a href="#"><?=_("Recover password") ?></a> | <a href="<?= url::site("user/register")?>"><?= _("Register") ?></a> | |