mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Use built-in login validation (#6434)
* Use built-in login validation * use button instead of submit to avoid duplicate submits --------- Co-authored-by: Simon Smith <simonsmith5521@gmail.com>
This commit is contained in:
		
							parent
							
								
									ac27034542
								
							
						
					
					
						commit
						63930c4b33
					
				
					 3 changed files with 12 additions and 48 deletions
				
			
		| 
						 | 
				
			
			@ -63,15 +63,15 @@
 | 
			
		|||
                                    <table>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td id=loginusername align=right width=100>Username:</td>
 | 
			
		||||
                                            <td><input id=username type=text autocomplete="username" maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) /></td>
 | 
			
		||||
                                            <td><input id=username type=text autocomplete="username" maxlength=64 name=username required /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td align=right>Password:</td>
 | 
			
		||||
                                            <td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off onchange=validateLogin(2) onkeyup=validateLogin(2,event) /></td>
 | 
			
		||||
                                            <td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off required /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td><div id=showPassHintLink style=display:none><a onclick=showPassHint() style="cursor:pointer">Show Hint</a></div></td>
 | 
			
		||||
                                            <td align=right><input id=loginButton type=submit value="Log In" disabled="disabled" /></td>
 | 
			
		||||
                                            <td align=right><input id=loginButton type=submit value="Log In" /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                    </table>
 | 
			
		||||
                                    <div id="hrAccountDiv" style="display:none"><hr /></div>
 | 
			
		||||
| 
						 | 
				
			
			@ -422,7 +422,6 @@
 | 
			
		|||
 | 
			
		||||
            window.onresize = center;
 | 
			
		||||
            center();
 | 
			
		||||
            validateLogin();
 | 
			
		||||
            validateCreate();
 | 
			
		||||
            if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
 | 
			
		||||
            QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
 | 
			
		||||
| 
						 | 
				
			
			@ -573,16 +572,6 @@
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateLogin(box, e) {
 | 
			
		||||
            setTimeout(function(){
 | 
			
		||||
                var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0));
 | 
			
		||||
                QE('loginButton', ok);
 | 
			
		||||
                setDialogMode(0);
 | 
			
		||||
                if ((e != null) && (e.keyCode == 13)) { if (box == 1) { Q('password').focus(); } else if (box == 2) { Q('loginButton').click(); } }
 | 
			
		||||
                if (e != null) { haltEvent(e); }
 | 
			
		||||
            }, 100);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateCreate(box,e) {
 | 
			
		||||
            setDialogMode(0);
 | 
			
		||||
            var ok = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -818,4 +807,4 @@
 | 
			
		|||
 | 
			
		||||
    </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,15 +55,15 @@
 | 
			
		|||
                                    <table>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td id=loginusername align=right width=100>Username:</td>
 | 
			
		||||
                                            <td><input id=username {{{autocomplete}}}="username" type=text maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) /></td>
 | 
			
		||||
                                            <td><input id=username {{{autocomplete}}}="username" type=text maxlength=64 name=username required /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td align=right>Password:</td>
 | 
			
		||||
                                            <td><input id=password {{{autocomplete}}}="current-password" type=password maxlength=256 name=password onchange=validateLogin(2) onkeyup=validateLogin(2,event) /></td>
 | 
			
		||||
                                            <td><input id=password {{{autocomplete}}}="current-password" type=password maxlength=256 name=password required /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                        <tr>
 | 
			
		||||
                                            <td><div id=showPassHintLink style=display:none><a onclick="return showPassHint(event);" href="#" style="cursor:pointer">Show Hint</a></div></td>
 | 
			
		||||
                                            <td align=right><input id=loginButton type=submit value="Log In" disabled="disabled" /></td>
 | 
			
		||||
                                            <td align=right><input id=loginButton type=submit value="Log In" /></td>
 | 
			
		||||
                                        </tr>
 | 
			
		||||
                                    </table>
 | 
			
		||||
                                    <div id="hrAccountDiv" style="display:none"><hr /></div>
 | 
			
		||||
| 
						 | 
				
			
			@ -456,7 +456,6 @@
 | 
			
		|||
            window.onresize = center;
 | 
			
		||||
            center();
 | 
			
		||||
 | 
			
		||||
            validateLogin();
 | 
			
		||||
            validateCreate();
 | 
			
		||||
            if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
 | 
			
		||||
            QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
 | 
			
		||||
| 
						 | 
				
			
			@ -661,16 +660,6 @@
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateLogin(box, e) {
 | 
			
		||||
            setTimeout(function(){
 | 
			
		||||
                var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0));
 | 
			
		||||
                QE('loginButton', ok);
 | 
			
		||||
                setDialogMode(0);
 | 
			
		||||
                if ((e != null) && (e.keyCode == 13)) { if ((box == 1) && (Q('username').value != '')) { Q('password').focus(); } else if ((box == 2) && (Q('password').value != '')) { Q('loginButton').click(); } }
 | 
			
		||||
                if (e != null) { haltEvent(e); }
 | 
			
		||||
            }, 100);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateCreate(box, e) {
 | 
			
		||||
            setDialogMode(0);
 | 
			
		||||
            var userok = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -971,4 +960,4 @@
 | 
			
		|||
 | 
			
		||||
    </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,12 +69,12 @@
 | 
			
		|||
                            <table style="width:100%">
 | 
			
		||||
                                <tr>
 | 
			
		||||
                                    <td>
 | 
			
		||||
                                        <input id=username title="Username" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="username" placeholder="Username" type=text maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) />
 | 
			
		||||
                                        <input id=username title="Username" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="username" placeholder="Username" type=text maxlength=64 name=username required />
 | 
			
		||||
                                    </td>
 | 
			
		||||
                                </tr>
 | 
			
		||||
                                <tr>
 | 
			
		||||
                                    <td>
 | 
			
		||||
                                        <input id=password title="Password" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="current-password" placeholder="Password" type=password maxlength=256 name=password onchange=validateLogin(2) onkeyup=validateLogin(2,event) />
 | 
			
		||||
                                        <input id=password title="Password" style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:8px;background-color:#FFF8CC" {{{autocomplete}}}="current-password" placeholder="Password" type=password maxlength=256 name=password required />
 | 
			
		||||
                                    </td>
 | 
			
		||||
                                </tr>
 | 
			
		||||
                                <tr>
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +84,7 @@
 | 
			
		|||
                                </tr>
 | 
			
		||||
                                <tr>
 | 
			
		||||
                                    <td>
 | 
			
		||||
                                        <input id=loginButton style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:6px" onclick="submitButtonClicked('loginpanelform')" type=button value="Log In" disabled="disabled" />
 | 
			
		||||
                                        <input id=loginButton style="box-sizing:border-box;width:280px;border:0;border-radius:4px;padding:6px" onclick="submitButtonClicked('loginpanelform')" type=button value="Log In" />
 | 
			
		||||
                                    </td>
 | 
			
		||||
                                </tr>
 | 
			
		||||
                                <tr id="topLanguageSelectRow" style="display:none"><td id="topLanguageSelect"></td></tr>
 | 
			
		||||
| 
						 | 
				
			
			@ -529,7 +529,6 @@
 | 
			
		|||
                if (authStrategies.indexOf('saml') >= 0) { QV('auth-saml', true); }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            validateLogin();
 | 
			
		||||
            validateCreate();
 | 
			
		||||
            if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
 | 
			
		||||
            QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
 | 
			
		||||
| 
						 | 
				
			
			@ -772,19 +771,6 @@
 | 
			
		|||
            if (!formSubmitted) { formSubmitted = true; document.getElementById(v).submit(); }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateLogin(box, e) {
 | 
			
		||||
            setTimeout(function(){
 | 
			
		||||
                var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0));
 | 
			
		||||
                QE('loginButton', ok);
 | 
			
		||||
                setDialogMode(0);
 | 
			
		||||
                if ((e != null) && (e.keyCode == 13)) {
 | 
			
		||||
                    if ((box == 1) && (Q('username').value != '')) { Q('password').focus(); }
 | 
			
		||||
                    else if ((box == 2) && (Q('password').value != '')) { Q('loginButton').click(); }
 | 
			
		||||
                }
 | 
			
		||||
                if (e != null) { haltEvent(e); }
 | 
			
		||||
            }, 100);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function validateCreate(box, e) {
 | 
			
		||||
            setDialogMode(0);
 | 
			
		||||
            var userok = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -1041,4 +1027,4 @@
 | 
			
		|||
 | 
			
		||||
    </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue