Skip to content

Commit c89158e

Browse files
committed
Check for invalid characters in username and password
1 parent 2a91ad6 commit c89158e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Diff for: CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CSP MySQL User Manager Changelog
99
3.2.0 [not yet released]
1010
[+] Enable/disable groups
1111
[+] Override and force database upgrade
12+
[+] Check for invalid characters in username and password
1213
[#] Changed update check url for new releases
1314
[#] Removed cmum dbversion from database
1415

Diff for: js/ajaxcalls.js

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ function checkusername() {
88
} else if(password=="") {
99
newuser.password.focus();
1010
}
11+
} else if(alphanumeric(username)==false || alphanumeric(password)==false) {
12+
if(alphanumeric(username)==false) {
13+
toastr.error('Username contains invalid characters');
14+
newuser.user.focus();
15+
} else if(alphanumeric(password)==false) {
16+
toastr.error('Password contains invalid characters');
17+
newuser.password.focus();
18+
}
1119
} else {
1220
jQuery.ajax({
1321
type: 'post',
@@ -38,6 +46,14 @@ function checkeditusername() {
3846
if(username=="") {
3947
edituser.user.focus();
4048
}
49+
} else if(alphanumeric(username)==false || alphanumeric(password)==false) {
50+
if(alphanumeric(username)==false) {
51+
toastr.error('Username contains invalid characters');
52+
newuser.user.focus();
53+
} else if(alphanumeric(password)==false) {
54+
toastr.error('Password contains invalid characters');
55+
newuser.password.focus();
56+
}
4157
} else {
4258
if(username!=rusername) {
4359
jQuery.ajax({

Diff for: js/cmum.js

+9
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,13 @@ function checksearch(e) {
5454
$('#newsearch').trigger('submit', true);
5555
}
5656
}
57+
}
58+
59+
function alphanumeric(inputtxt) {
60+
var letters = /^[0-9a-zA-Z]+$/;
61+
if (letters.test(inputtxt)) {
62+
return true;
63+
} else {
64+
return false;
65+
}
5766
}

0 commit comments

Comments
 (0)