$.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();
}
}
+ 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) {
$('#topbar-menu-container').html($("#topbar-menu"));
$('#sidebar-content').html($("#main-menu"));
- checkCreateAdminLink();
hideElementWithKarma();
checkSecurityLinks();
+ checkCreateAdminLink();
}
startArchivaApplication();
})
});
/**
- * 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'));
}
});
\ No newline at end of file