PHP8
[Pman.BAdmin] / Pman.Login.js
index fd026f7..77fb3b4 100644 (file)
@@ -51,7 +51,7 @@ Pman.Login =  new Roo.util.Observable({
         // check if we are logged in..
         new Pman.Request({  
             url: baseURL + '/Login',
-            method: 'GET',  
+            method: 'POST',  
             params: {
                 getAuthUser: true
             },  
@@ -67,6 +67,7 @@ Pman.Login =  new Roo.util.Observable({
                     //console.log('call failure');
                     return Pman.Login.failure(response,opts);
                 }
+                
                 if (res.data.id*1 < 0) {
                     this.fillAuth(res.data);
                     return this.openSystem();
@@ -74,7 +75,19 @@ Pman.Login =  new Roo.util.Observable({
                     
                 var _this = this;
                 if (!res.data.id) { // id=0 == login failure.
-                    return Pman.Dialog.Login.show({},
+                    
+                    if(window.location.pathname.substr(baseURL.length).match(/\/PasswordReset\//)){
+                        Pman.Dialog.BAdminPasswordReset.show({}, function(){
+                            window.location.href = baseURL;
+                        });
+                        
+                        return;
+                    }
+                     
+                    
+                    
+                    return Pman.Dialog.Login.show(
+                        {},
                         function(data) {
                            Pman.Login.success(data);
                         }
@@ -126,7 +139,7 @@ Pman.Login =  new Roo.util.Observable({
             params: {
                 getAuthUser: true
             },  
-            method: 'GET',  
+            method: 'POST',  
             success:  Pman.Login.success,
             failure : Pman.Login.failure,
             scope : Pman.Login
@@ -379,22 +392,36 @@ Pman.Login =  new Roo.util.Observable({
         
         new Pman.Request({  
             url: baseURL + '/Login',
-            method: 'GET',  
+            method: 'POST',  
             params: {
-                checkOwnerCompany: true
+                check_owner_company: true
             },  
             success:  function(res)  {  // check successfull...
                 
-                if(!res.data.owner_company) {
+                if(res.data == 1) {
+                    this.openSystemCreateUser();
+                    return;
+                }
+                
+                if(res.data == 0) {
                     this.openSystemCreateCompany();
                     return;
                 }
                 
-                this.openSystemCreateUser();
+                if(res.data > 0) {
+                    Roo.bootstrap.MessageBox.alert(
+                        "Error",  
+                        "There are more than 1 company in the system. please fix the data"
+                    );
+                    return;
+                }
             },
             failure : function(res)
             {
-                Roo.log('invalid params');
+                Roo.bootstrap.MessageBox.alert(
+                    "Error",  
+                    "Invalid params for check owner company"
+                );
             },
             scope : Pman.Login
         });