We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    This is strange one!

    I need to create a members area on my site.
    But, there are about 7,000 members to add, and we need the login to be faked, so that the username is ANY six digit number, and the password is the same for everyone.

    So essentially we need one user that multiple members can use st the same time and the username is any six digit number.

    I know it sounds odd, but the reason is that the members are registered offline and so people join and leave all the time. A lot of members don't even have email addresses so we have to go it this way! Ang ideas on how to tackle this?


    Andy
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      One username, or a unique username for each user and just one password? You can always specify the password when you create a user.
        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
        • 51020
        • 670 Posts
        Thanks Susan - that would be fine, but the problem I have is that we need the username to be ANY six digit number, e.g.:

        un:
        123456
        pw:
        toffee

        or

        un:
        654321

        pw:
        toffee

        Basically, all members already have a membership number that they received by post.
        So rather than feeding those in (as they are updated every day) they just want to let anyone with a six digit membership number to use that as their username?

        Does that make sense?


          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I see. Not particularly secure, I hope that it's nothing really sensitive or important in there.

          I would use a single MODX user, and use one of the OnBefore... events to check the validity of the username and if it's a valid 6-digit number, change it to the single user's username then continue the login as usual. Would take a bit of trial-and-error to figure out which event, though.

          Upon looking at the rtfm, it should probably be OnWebAuthentication but this one presumes the username and lets you fiddle with the password only. Would a global username, and the password being the 6-digit number, work for you? https://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins/system-events/onwebauthentication

          Otherwise it'll have to be the OnBeforeWebLogin, which might be tricky - its default purpose is to deny login. You need to make sure to use $modx->event->output(true); at the end in order to allow the login process to continue. https://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins/system-events/onbeforeweblogin
            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
            • 51020
            • 670 Posts
            OK great - thanks so much for your time on this - I will have a play with your suggestions and see if i can get it to work - thanks again - I love this community - I hope that soon I'll be in a position where I can answer other people's problems for a change!! smiley