mirror of https://github.com/apache/archiva.git
use a callback pattern with non blocking call to check admin exists and menu entries needed karmas
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1234883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
291bf447e5
commit
5475f8d4f9
|
@ -114,11 +114,8 @@ $(function() {
|
|||
$.log("hideElementWithKarma");
|
||||
}
|
||||
|
||||
|
||||
checkSecurityLinks=function(){
|
||||
$.log("checkSecurityLinks");
|
||||
var user = userLogged();
|
||||
$.log("checkSecurityLinks, user:"+user);
|
||||
userLoggedCallbackFn=function(user){
|
||||
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
|
||||
|
||||
if (!user) {
|
||||
$("#login-link").show();
|
||||
|
@ -133,11 +130,14 @@ $(function() {
|
|||
}
|
||||
}
|
||||
|
||||
checkSecurityLinks=function(){
|
||||
userLogged(userLoggedCallbackFn);
|
||||
}
|
||||
|
||||
checkCreateAdminLink=function(){
|
||||
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
async: false,
|
||||
success: function(data) {
|
||||
var adminExists = JSON.parse(data);
|
||||
if (adminExists == false) {
|
||||
|
@ -165,9 +165,9 @@ $(function() {
|
|||
$('#topbar-menu-container').html($("#topbar-menu"));
|
||||
$('#sidebar-content').html($("#main-menu"));
|
||||
|
||||
checkCreateAdminLink();
|
||||
hideElementWithKarma();
|
||||
checkSecurityLinks();
|
||||
checkCreateAdminLink();
|
||||
}
|
||||
startArchivaApplication();
|
||||
})
|
||||
|
|
|
@ -32,25 +32,22 @@ $(function() {
|
|||
});
|
||||
|
||||
/**
|
||||
* return a user see user.js if user logged otherwise null
|
||||
* call successFn on success with passing user object coming from cookie
|
||||
*/
|
||||
userLogged=function() {
|
||||
userLogged=function(successFn) {
|
||||
// call restServices/redbackServices/loginService/isLogged to know
|
||||
// if a session exists and check the cookie
|
||||
$.log("userLogged");
|
||||
var userLogged = true;
|
||||
$.ajax("restServices/redbackServices/loginService/isLogged", {
|
||||
type: "GET",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
userLogged = JSON.parse(data);
|
||||
if (successFn){
|
||||
successFn(userLogged == false ? null : jQuery.parseJSON($.cookie('redback_login')));
|
||||
}
|
||||
}
|
||||
});
|
||||
if (userLogged == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return jQuery.parseJSON($.cookie('redback_login'));
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in New Issue