Permalink
Browse files

Single admin account now working.

  • Loading branch information...
benkeen committed Jan 11, 2013
1 parent 39a6a81 commit 4fe6c291861806cbe30513c9ed66d6ba396cb893
View
@@ -3,6 +3,9 @@
require_once("library.php");
Core::init();
+// if need be, redirect to the install instructions page
+Utils::maybeShowInstallationPage();
+
if (Core::checkIsLoggedIn()) {
header("location: ./");
exit;
@@ -98,6 +98,10 @@ public static function login($email, $password) {
);
}
+ public static function logout() {
+ session_destroy();
+ }
+
public function getAccount() {
return array(
"isAnonymous" => $this->isAnonymous,
@@ -257,10 +257,14 @@ public function __construct($action, $post = array()) {
$this->response["content"] = $response["message"];
break;
-/*
+ // for single
case "logout":
+ Core::init();
+ if (!Core::$user->isAnonymous()) {
+ Core::$user->logout();
+ $this->response["success"] = true;
+ }
break;
-*/
}
}
View
@@ -244,3 +244,5 @@
$L["installation_complete_text"] = "The Data Generator has been successfully installed! Click the button below to go to the script.";
$L["please_login"] = "Please Login";
$L["forgotten_your_password_q"] = "Forgotten your password?";
+$L["admin"] = "Admin";
+$L["logout"] = "Logout";
@@ -125,7 +125,7 @@ define([
$("#gdDataSetLink").on("click", _openDataSetLinkDialog);
// main dialog
- $("#gdUserAccountLink").on("click", function() { return _openMainDialog({ tab: 1 }); });
+ $("#gdLogout").on("click", function() { return _logout(); });
$("#gdLoadLink").on("click", function() { return _openMainDialog({ tab: 2 }); });
$("#gdAccountDataSets").on("click", "a", _onClickLoadDataSet);
$("#gdAccountDataSets").on("change", ".gdDeleteDataSets", _onChangeMarkDataSetRowToDelete);
@@ -1363,7 +1363,7 @@ define([
if (_accountInfo.isAnonymous) {
$("#gdAccount_AccountType").html(L.anonymous_admin_account);
} else {
- // TODO
+ $("#gdAccount_AccountType").html(L.admin);
}
$("#gdAccount_NumSavedDataSets").html(_dataSets.length);
@@ -1587,6 +1587,23 @@ define([
}
};
+ var _logout = function() {
+ $.ajax({
+ url: "ajax.php",
+ type: "POST",
+ dataType: "json",
+ data: {
+ action: "logout"
+ },
+ success: function(response) {
+ if (response.success) {
+ window.location = "login.php";
+ }
+ },
+ error: function() {
+ }
+ });
+ };
// register our module
manager.registerCoreModule(MODULE_ID, {
@@ -25,7 +25,7 @@
<body>
<header>
<nav>
- {if $settings.userAccountSetup != "anonymous"}<a href="#" id="gdUserAccountLink">{$L.your_account}</a> |{/if}
+ {if $settings.userAccountSetup != "anonymous"}<a href="#" id="gdLogout">{$L.logout}</a> |{/if}
<a href="http://www.generatedata.com">{$L.website}</a> |
<a href="http://www.benjaminkeen.com/category/projects/data-generator/">{$L.blog}</a> |
{language_dropdown nameId="gdSelectLanguage" disabled=true}
Binary file not shown.
@@ -265,14 +265,6 @@ li.gdColDelete {
width: 260px;
margin-right: 3px;
}
-#gdUserAccountLink:before {
- content: "";
- background: transparent url(../images/user.png) left center no-repeat;
- width: 20px;
- height: 16px;
- margin-bottom: -3px;
- display: inline-block;
-}
#gdActionIcons {
float: right;
list-style: none;

0 comments on commit 4fe6c29

Please sign in to comment.