$('#topbar-menu-container').html($("#topbar-menu"));
$('#sidebar-content').html($("#main-menu"));
-
- $.ajax("restServices/redbackServices/userService/isAdminUserExists", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var adminExists = JSON.parse(data);
- if (adminExists == false) {
- $("#create-admin-link").show();
+ checkCreateAdminLink=function(){
+ $.ajax("restServices/redbackServices/userService/isAdminUserExists", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var adminExists = JSON.parse(data);
+ if (adminExists == false) {
+ $("#create-admin-link").show();
+ } else {
+ $("#create-admin-link").hide();
+ }
}
- }
- });
+ });
+ }
+ checkCreateAdminLink();
hideElementWithKarma();
- var user = userLogged();
- if (!user) {
- $("#login-link").show();
- $("#register-link").show();
- $("#change-password-link").hide();
- } else {
- $("#change-password-link").show();
- $("#logout-link").show();
- decorateMenuWithKarma(user);
+ checkSecurityLinks=function(){
+ var user = userLogged();
+ $.log("checkSecurityLinks, user:"+user);
+
+ if (!user) {
+ $("#login-link").show();
+ $("#register-link").show();
+ $("#change-password-link").hide();
+ } else {
+ $("#change-password-link").show();
+ $("#logout-link").show();
+ $("#register-link").hide();
+ $("#login-link").hide();
+ decorateMenuWithKarma(user);
+ }
}
+ checkSecurityLinks();
/**
}
screenChange=function(){
+ $("#main-content").html("");
clearUserMessages();
}
if (!valid) {
return;
}
-
+ var currentAdminUser = this;
$.ajax("restServices/redbackServices/userService/createAdminUser", {
data: "{\"user\": " + ko.toJSON(this)+"}",
contentType: 'application/json',
var created = JSON.parse(result);
if (created == true) {
displaySuccessMessage("admin user created");
+ loginCall(currentAdminUser.username(), currentAdminUser.password(),function(){screenChange();checkCreateAdminLink();checkSecurityLinks();});
return this;
} else {
displayErrorMessage("admin user not created");