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");
|
$.log("hideElementWithKarma");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userLoggedCallbackFn=function(user){
|
||||||
checkSecurityLinks=function(){
|
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
|
||||||
$.log("checkSecurityLinks");
|
|
||||||
var user = userLogged();
|
|
||||||
$.log("checkSecurityLinks, user:"+user);
|
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
$("#login-link").show();
|
$("#login-link").show();
|
||||||
|
@ -133,11 +130,14 @@ $(function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSecurityLinks=function(){
|
||||||
|
userLogged(userLoggedCallbackFn);
|
||||||
|
}
|
||||||
|
|
||||||
checkCreateAdminLink=function(){
|
checkCreateAdminLink=function(){
|
||||||
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
|
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var adminExists = JSON.parse(data);
|
var adminExists = JSON.parse(data);
|
||||||
if (adminExists == false) {
|
if (adminExists == false) {
|
||||||
|
@ -165,9 +165,9 @@ $(function() {
|
||||||
$('#topbar-menu-container').html($("#topbar-menu"));
|
$('#topbar-menu-container').html($("#topbar-menu"));
|
||||||
$('#sidebar-content').html($("#main-menu"));
|
$('#sidebar-content').html($("#main-menu"));
|
||||||
|
|
||||||
checkCreateAdminLink();
|
|
||||||
hideElementWithKarma();
|
hideElementWithKarma();
|
||||||
checkSecurityLinks();
|
checkSecurityLinks();
|
||||||
|
checkCreateAdminLink();
|
||||||
}
|
}
|
||||||
startArchivaApplication();
|
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
|
// call restServices/redbackServices/loginService/isLogged to know
|
||||||
// if a session exists and check the cookie
|
// if a session exists and check the cookie
|
||||||
$.log("userLogged");
|
$.log("userLogged");
|
||||||
var userLogged = true;
|
var userLogged = true;
|
||||||
$.ajax("restServices/redbackServices/loginService/isLogged", {
|
$.ajax("restServices/redbackServices/loginService/isLogged", {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
userLogged = JSON.parse(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