mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
bb5b701d93
|
@ -56,6 +56,8 @@ edge attribute `label`.
|
||||||
v3.1.9 (XXXX-XX-XX)
|
v3.1.9 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* ui: fixed re-login issue within a non system db, when tab was closed
|
||||||
|
|
||||||
* fixed a race in the VelocyStream Commtask implementation
|
* fixed a race in the VelocyStream Commtask implementation
|
||||||
|
|
||||||
* fixed issue #2256
|
* fixed issue #2256
|
||||||
|
|
|
@ -48,8 +48,13 @@
|
||||||
return localStorage.getItem('jwt');
|
return localStorage.getItem('jwt');
|
||||||
},
|
},
|
||||||
|
|
||||||
setCurrentJwt: function (jwt) {
|
getCurrentJwtUsername: function () {
|
||||||
|
return localStorage.getItem('jwtUser');
|
||||||
|
},
|
||||||
|
|
||||||
|
setCurrentJwt: function (jwt, username) {
|
||||||
localStorage.setItem('jwt', jwt);
|
localStorage.setItem('jwt', jwt);
|
||||||
|
localStorage.setItem('jwtUser', username);
|
||||||
},
|
},
|
||||||
|
|
||||||
lastNotificationMessage: null,
|
lastNotificationMessage: null,
|
||||||
|
|
|
@ -51,9 +51,8 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).success(
|
}).success(
|
||||||
function (data) {
|
function (data) {
|
||||||
arangoHelper.setCurrentJwt(data.jwt);
|
|
||||||
|
|
||||||
var jwtParts = data.jwt.split('.');
|
var jwtParts = data.jwt.split('.');
|
||||||
|
|
||||||
if (!jwtParts[1]) {
|
if (!jwtParts[1]) {
|
||||||
throw new Error('Invalid JWT');
|
throw new Error('Invalid JWT');
|
||||||
}
|
}
|
||||||
|
@ -61,14 +60,21 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
if (!window.atob) {
|
if (!window.atob) {
|
||||||
throw new Error('base64 support missing in browser');
|
throw new Error('base64 support missing in browser');
|
||||||
}
|
}
|
||||||
var payload = JSON.parse(atob(jwtParts[1]));
|
|
||||||
|
|
||||||
|
var payload = JSON.parse(atob(jwtParts[1]));
|
||||||
self.activeUser = payload.preferred_username;
|
self.activeUser = payload.preferred_username;
|
||||||
|
|
||||||
|
if (self.activeUser === undefined) {
|
||||||
|
arangoHelper.setCurrentJwt(data.jwt, null);
|
||||||
|
} else {
|
||||||
|
arangoHelper.setCurrentJwt(data.jwt, self.activeUser);
|
||||||
|
}
|
||||||
|
|
||||||
callback(false, self.activeUser);
|
callback(false, self.activeUser);
|
||||||
}
|
}
|
||||||
).error(
|
).error(
|
||||||
function () {
|
function () {
|
||||||
arangoHelper.setCurrentJwt(null);
|
arangoHelper.setCurrentJwt(null, null);
|
||||||
self.activeUser = null;
|
self.activeUser = null;
|
||||||
callback(true, null);
|
callback(true, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,17 @@
|
||||||
|
|
||||||
render: function (loggedIn) {
|
render: function (loggedIn) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
$(this.el).html(this.template.render({}));
|
$(this.el).html(this.template.render({}));
|
||||||
$(this.el2).hide();
|
$(this.el2).hide();
|
||||||
$(this.el3).hide();
|
$(this.el3).hide();
|
||||||
|
|
||||||
if (frontendConfig.authenticationEnabled && loggedIn !== true) {
|
var continueRender = function (user, errCallback) {
|
||||||
window.setTimeout(function () {
|
var url;
|
||||||
$('#loginUsername').focus();
|
if (!user) {
|
||||||
}, 300);
|
url = arangoHelper.databaseUrl('/_api/database/user');
|
||||||
} else {
|
} else {
|
||||||
var url = arangoHelper.databaseUrl('/_api/database/user');
|
url = arangoHelper.databaseUrl('/_api/user/' + encodeURIComponent(user) + '/database', '_system');
|
||||||
|
}
|
||||||
|
|
||||||
if (frontendConfig.authenticationEnabled === false) {
|
if (frontendConfig.authenticationEnabled === false) {
|
||||||
$('#logout').hide();
|
$('#logout').hide();
|
||||||
|
@ -47,17 +47,45 @@
|
||||||
// enable db select and login button
|
// enable db select and login button
|
||||||
$('#loginDatabase').html('');
|
$('#loginDatabase').html('');
|
||||||
// fill select with allowed dbs
|
// fill select with allowed dbs
|
||||||
|
_.each(permissions.result, function (rule, db) {
|
||||||
_.each(permissions.result, function (db) {
|
if (errCallback) {
|
||||||
$('#loginDatabase').append(
|
$('#loginDatabase').append(
|
||||||
'<option>' + db + '</option>'
|
'<option>' + db + '</option>'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$('#loginDatabase').append(
|
||||||
|
'<option>' + rule + '</option>'
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.renderDBS();
|
self.renderDBS();
|
||||||
}).error(function () {
|
}).error(function () {
|
||||||
|
if (errCallback) {
|
||||||
|
errCallback();
|
||||||
|
} else {
|
||||||
console.log('could not fetch user db data');
|
console.log('could not fetch user db data');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (frontendConfig.authenticationEnabled && loggedIn !== true) {
|
||||||
|
var usr = arangoHelper.getCurrentJwtUsername();
|
||||||
|
if (usr !== null && usr !== 'undefined' && usr !== undefined) {
|
||||||
|
// try if existent jwt is valid
|
||||||
|
var errCallback = function () {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
$('#loginUsername').focus();
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
continueRender(arangoHelper.getCurrentJwtUsername(), errCallback);
|
||||||
|
} else {
|
||||||
|
window.setTimeout(function () {
|
||||||
|
$('#loginUsername').focus();
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continueRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.bodyWrapper').show();
|
$('.bodyWrapper').show();
|
||||||
|
@ -132,6 +160,12 @@
|
||||||
'<option>_system</option>'
|
'<option>_system</option>'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
self.renderDBSelection(username);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
renderDBSelection: function (username) {
|
||||||
|
var self = this;
|
||||||
var url = arangoHelper.databaseUrl('/_api/user/' + encodeURIComponent(username) + '/database', '_system');
|
var url = arangoHelper.databaseUrl('/_api/user/' + encodeURIComponent(username) + '/database', '_system');
|
||||||
|
|
||||||
if (frontendConfig.authenticationEnabled === false) {
|
if (frontendConfig.authenticationEnabled === false) {
|
||||||
|
@ -167,7 +201,6 @@
|
||||||
}).error(function () {
|
}).error(function () {
|
||||||
$('.wrong-credentials').show();
|
$('.wrong-credentials').show();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
renderDBS: function () {
|
renderDBS: function () {
|
||||||
|
|
Loading…
Reference in New Issue