[fix] Postinstall & login

This commit is contained in:
kload 2014-05-25 21:11:47 +00:00
parent e092b9beff
commit 7eae04b1b9

View file

@ -93,7 +93,7 @@ app = Sammy('#main', function (sam) {
}); });
}, },
isInstalled: function() { checkInstall: function(callback) {
domain = window.location.hostname; domain = window.location.hostname;
$.ajax({ $.ajax({
dataType: "json", dataType: "json",
@ -101,10 +101,10 @@ app = Sammy('#main', function (sam) {
timeout: 3000 timeout: 3000
}) })
.success(function(data) { .success(function(data) {
return data.installed; callback(data.installed);
}) })
.fail(function() { .fail(function() {
return false; callback(false);
}); });
}, },
@ -227,10 +227,12 @@ app = Sammy('#main', function (sam) {
if (window.location.hostname === args.domain) { if (window.location.hostname === args.domain) {
window.open('https://'+ args.domain +'/yunohost/admin'); window.open('https://'+ args.domain +'/yunohost/admin');
} else { } else {
if (!c.isInstalled()) { c.checkInstall(function(isInstalled) {
c.flash('success', y18n.t('installation_complete')); if (isInstalled) {
c.redirect('#/login'); c.flash('success', y18n.t('installation_complete'));
} c.redirect('#/login');
}
});
} }
}, 5000); }, 5000);
} else { } else {
@ -367,9 +369,14 @@ app = Sammy('#main', function (sam) {
$('#masthead').show(); $('#masthead').show();
$('.logout-button').hide(); $('.logout-button').hide();
store.set('path-1', '#/login'); store.set('path-1', '#/login');
if (!c.isInstalled()) { c.checkInstall(function(isInstalled) {
c.redirect('#/postinstall'); if (isInstalled) {
} domain = window.location.hostname;
c.view('login', { 'domain': domain });
} else {
c.view('login');
}
});
}); });
sam.post('#/login', function (c) { sam.post('#/login', function (c) {