We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28359
    • 9 Posts
    It just struck me that I could register as ’admin’ on the Frontend!

    It would be good if WebSignup is modified to look at and check against a list of reserved login names thus disallowing web users to register with certain usernames like webmaster, admin, administrator, moderator, manager, etc. , the list being specified by Role ID1. Such a list of "Reserved usernames" for WebSignup may prevent quite a few headaches; and will be good and wise to have.

    Stan
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Make a custom handler for the "OnBeforeWebSaveUser" event and compare the username submitted against an array of disallowed names, and return an error message in case of a match.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28359
        • 9 Posts
        Thanks very much Susan.

        It seems really simple, but it’s way beyond my php skills and db knowledge (of which I have very little, if not none at all). That’s why I put it in the Wishlist, hoping that someone more knowledgeable than me would code it.

        Stan
          • 28359
          • 9 Posts
          Ok, I decided to try something myself. Be sympathetic to the newbie, pls. smiley

          What I could think of so far is, add this to the websignup.inc.php

              // check for duplicate user name
              if($username=="") {
                  $output = webLoginAlert("Missing username. Please enter a user name.").$tpl;
                  return;
              }
          
          // MY Reserved signup
             elseif ($username=="array(
                                  admin,
                                  manager)"); {
                              $output=webLoginAlert("You cannot signup with this username!").$tpl;
                           return;
                          }
                                                  
          // END MY Reserved signup
          
              else {
                  $sql = "SELECT id FROM ".$modx->getFullTableName("web_users")." WHERE username='$username'";
                  if(!$rs = $modx->db->query($sql)){
                      $output = webLoginAlert("An error occured while attempting to retreive all users with username $username.").$tpl;
                      return;
                  } 
                  $limit = $modx->db->getRecordCount($rs);
                  if($limit>0) {
                      $output = webLoginAlert("Username is already in use!").$tpl;
                      return;
                  }        
              }


          Can anyone tell me what’s wrong?

          Thanks a zillion in advance.
            • 28359
            • 9 Posts
            Thanks a lot, I’ll give it a try as soon as I can.
              • 28359
              • 9 Posts
              Awesome! Working perfectly!

              Thanks very much ganeshXL!