Skip to content
Permalink
Browse files Browse the repository at this point in the history
Check for invalid characters in username and password
  • Loading branch information
dukereborn committed Apr 26, 2015
1 parent 2a91ad6 commit c89158e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,7 @@ CSP MySQL User Manager Changelog
3.2.0 [not yet released]
[+] Enable/disable groups
[+] Override and force database upgrade
[+] Check for invalid characters in username and password
[#] Changed update check url for new releases
[#] Removed cmum dbversion from database

Expand Down
16 changes: 16 additions & 0 deletions js/ajaxcalls.js
Expand Up @@ -8,6 +8,14 @@ function checkusername() {
} else if(password=="") {
newuser.password.focus();
}
} else if(alphanumeric(username)==false || alphanumeric(password)==false) {
if(alphanumeric(username)==false) {
toastr.error('Username contains invalid characters');
newuser.user.focus();
} else if(alphanumeric(password)==false) {
toastr.error('Password contains invalid characters');
newuser.password.focus();
}
} else {
jQuery.ajax({
type: 'post',
Expand Down Expand Up @@ -38,6 +46,14 @@ function checkeditusername() {
if(username=="") {
edituser.user.focus();
}
} else if(alphanumeric(username)==false || alphanumeric(password)==false) {
if(alphanumeric(username)==false) {
toastr.error('Username contains invalid characters');
newuser.user.focus();
} else if(alphanumeric(password)==false) {
toastr.error('Password contains invalid characters');
newuser.password.focus();
}
} else {
if(username!=rusername) {
jQuery.ajax({
Expand Down
9 changes: 9 additions & 0 deletions js/cmum.js
Expand Up @@ -54,4 +54,13 @@ function checksearch(e) {
$('#newsearch').trigger('submit', true);
}
}
}

function alphanumeric(inputtxt) {
var letters = /^[0-9a-zA-Z]+$/;
if (letters.test(inputtxt)) {
return true;
} else {
return false;
}
}

0 comments on commit c89158e

Please sign in to comment.