]> source.dussan.org Git - archiva.git/commitdiff
automatic login after admin user creation
authorOlivier Lamy <olamy@apache.org>
Fri, 9 Dec 2011 14:49:39 +0000 (14:49 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 9 Dec 2011 14:49:39 +0000 (14:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1212452 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js

index 2622f4a0a6740c13a3480f525d05de33feb143a8..94fc3f63ea129fe4786473441a6e0f9880421583 100644 (file)
@@ -133,31 +133,42 @@ function($) {
       $('#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();
 
 
       /**
@@ -199,6 +210,7 @@ function($) {
       }
 
       screenChange=function(){
+        $("#main-content").html("");
         clearUserMessages();
       }
 
index 4454dc801be1d277d5c345538c897073b9709707..f3d20330ea941736031bf04db3a1f01f4d47bde9 100644 (file)
@@ -79,7 +79,7 @@ $(function() {
         if (!valid) {
             return;
         }
-
+        var currentAdminUser = this;
         $.ajax("restServices/redbackServices/userService/createAdminUser", {
             data: "{\"user\": " +  ko.toJSON(this)+"}",
             contentType: 'application/json',
@@ -89,6 +89,7 @@ $(function() {
               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");