[fix] Better login handling

This commit is contained in:
kload 2014-06-07 12:51:36 +00:00
parent 2cb0deca25
commit 2bed7f8cd0

View file

@ -201,8 +201,13 @@ app = Sammy('#main', function (sam) {
}) })
.fail(function(xhr) { .fail(function(xhr) {
// console.log('fail');console.log(xhr); // console.log('fail');console.log(xhr);
if (xhr.status == 401) { if (xhr.status == 200) {
if (uri !== '/login') { // Fail with 200, WTF
callback({});
} else if (xhr.status == 401) {
if (uri === '/login') {
c.flash('fail', y18n.t('wrong_password'));
} else {
c.flash('fail', y18n.t('unauthorized')); c.flash('fail', y18n.t('unauthorized'));
c.redirect('#/login'); c.redirect('#/login');
} }