Simplified response of session init

This commit is contained in:
Tobias Reich 2015-03-06 23:29:55 +01:00
parent b143de1050
commit d01e894220
5 changed files with 51 additions and 22 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -17,8 +17,7 @@ class Installation extends Access {
case 'Database::createConfig': $this->dbCreateConfig(); break;
# Error
default: exit('Warning: No configuration!');
return false; break;
default: $this->init(); break;
}
@ -33,6 +32,16 @@ class Installation extends Access {
}
private function init() {
$return = array(
'status' => LYCHEE_STATUS_NOCONFIG
);
echo json_encode($return);
}
}
?>

View File

@ -8,6 +8,11 @@
# Define root
define('LYCHEE', substr(__DIR__, 0, -3));
# Define status
define('LYCHEE_STATUS_NOCONFIG', 0);
define('LYCHEE_STATUS_LOGGEDOUT', 1);
define('LYCHEE_STATUS_LOGGEDIN', 2);
# Define dirs
define('LYCHEE_DATA', LYCHEE . 'data/');
define('LYCHEE_SRC', LYCHEE . 'src/');

View File

@ -55,10 +55,13 @@ class Session extends Module {
if ($public===false) {
# Logged in
$return['loggedIn'] = true;
$return['status'] = LYCHEE_STATUS_LOGGEDIN;
} else {
# Logged out
$return['status'] = LYCHEE_STATUS_LOGGEDOUT;
# Unset unused vars
unset($return['config']['username']);
unset($return['config']['thumbQuality']);
@ -68,9 +71,6 @@ class Session extends Module {
unset($return['config']['location']);
unset($return['config']['plugins']);
# Logged out
$return['loggedIn'] = false;
}
# Call plugins

View File

@ -41,30 +41,45 @@ lychee.init = function() {
api.post('Session::init', params, function(data) {
if (data.loggedIn!==true) {
lychee.setMode('public');
} else {
lychee.username = data.config.username || '';
lychee.sorting = data.config.sorting || '';
lychee.dropboxKey = data.config.dropboxKey || '';
lychee.location = data.config.location || '';
}
// Check status
// 0 = No configuration
// 1 = Logged out
// 2 = Logged in
if (data.status===2) {
// Logged in
lychee.username = data.config.username || '';
lychee.sorting = data.config.sorting || '';
lychee.dropboxKey = data.config.dropboxKey || '';
lychee.location = data.config.location || '';
lychee.checkForUpdates = data.config.checkForUpdates || true;
// No username and password
if (data.config.login===false) settings.createLogin();
} else if (data.status===1) {
// Logged out
lychee.setMode('public');
} else if (data.status===0) {
// No configuration
lychee.setMode('public');
// No configuration
if (data==='Warning: No configuration!') {
header.dom().hide();
lychee.content.hide();
$('body').append(build.no_content('cog'));
settings.createConfig();
return true;
}
// No login
if (data.config.login===false) {
settings.createLogin();
}
lychee.checkForUpdates = data.config.checkForUpdates;
$(window).bind('popstate', lychee.load);
lychee.load();