Simplified response of session init

pull/331/head
Tobias Reich 9 years ago
parent b143de1050
commit d01e894220

2
dist/main.js vendored

File diff suppressed because one or more lines are too long

@ -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);
}
}
?>

@ -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/');

@ -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

@ -41,30 +41,45 @@ lychee.init = function() {
api.post('Session::init', params, function(data) {
if (data.loggedIn!==true) {
// 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');
} else {
lychee.username = data.config.username || '';
lychee.sorting = data.config.sorting || '';
lychee.dropboxKey = data.config.dropboxKey || '';
lychee.location = data.config.location || '';
}
// 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();

Loading…
Cancel
Save