We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39251
    • 53 Posts
    Wow, long time no post. Hi, all!
    MODX Revolution 2.5.7-pl, Login 1.9.3-pl

    I was contacted by an associate with questions about this, so I haven't been heavily working with Login recently myself, but I did install it on a test website and verified the issues they are having and the information they found. They aren't that familiar with MODX, I'm VERY familiar with it, so I'm trying to help.

    They were using a previous version and it was working, although they told me that various parts of it were inconsistent (as far as implementation), and they were unable to get a couple of the features to work. They had also had users reporting occasional problems they couldn't reproduce, including problems with registration confirmation that sound like they may have been fixed in v1.9.2.

    So now to v1.9.3. Unless we are all doing something wrong on both of our websites, their forms no longer validate correctly, and even the sample registration chunk that comes with it didn't show any validation errors when I submitted it blank, it just redisplayed. The changelog mentions things like "Normalize placeholder prefix usage" which I'm sure is the problem, but the readme file has only been updated through 1.9.2 and the online documentation doesn't seem to have been updated in a year or more. (The registration page shows over two years.)

    So these poor guys are over there going through the source code trying to figure out how to get all of this working. I've so far only glanced at the source, it looks like it may be using formit type validation? One of their snippet calls previously worked with formit parameters, others didn't, so this didn't surprise me, but that's the registration snippet that isn't showing errors any more.

    So I guess my biggest question is did someone document these changes anywhere or are we actually going to have to go through source code to figure out how to get this working? And unfortunately it's a huge rush because they'd taken the site down temporarily for upgrades and now this is holding things up for a few hundred users. But they don't want to revert because they'd still have to troubleshoot the other problems people were reporting, which they've already tried previously and not been able to track down. We're all hoping the new version magically makes those problems go away.

    I'm tempted to just help them rewrite it with all of the login snippets being called as formit hooks...

    P.S. Hi, Bob! Your site is still and probably always will be my go-to for MODX information. I need to talk to you about a book upgrade. smiley
    [ed. note: ocdcoder last edited this post 9 years, 4 months ago.]
      If there's a better way to do it, I'll find it.
      • 13428 ☆ A M B ☆
      • 1,031 Posts
      Hey, the changes could be seen on github in https://github.com/modxcms/Login/commit/b6da4981dae9aecf11270e620365cab3f0db1ae4

      If you tell me which things go wrong on that installation, I could maybe help you.
        • 39251
        • 53 Posts
        Oh, thank you! That's going to be extremely helpful! Although it doesn't look like anything was done to the Register placeholders, so that's still a mystery. And it turns out the previous version they had was 1.9.2, so those fixes won't help whatever is going on, but maybe with the fine-tooth comb troubleshooting we have planned, we can figure it out. They're giving me their code to duplicate on my site so we can see if there's anything else conflicting as well.

        Can you give me the link for comparing versions of Register? (Or tell me how to do it? Me and git do not, ahem, git along at all.)

        They want to start with Login since it should be the simplest. The problem they were having before with that one was the one most complained about, and was also random aka intermittent aka non-reproducible. They don't clear the password field when someone tries to log in and it fails, and they would have people email them to report that the first time it returned an invalid username/password message, they didn't change anything and submitted again, and it worked. One of them got it to do that once, but couldn't repeat it and couldn't find anything that caused it.

        Nice to meet you, by the way. Did you take over the project from splittingred?
          If there's a better way to do it, I'll find it.
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          Quote from: ocdcoder at May 14, 2017, 12:05 PM
          Can you give me the link for comparing versions of Register? (Or tell me how to do it? Me and git do not, ahem, git along at all.)

          Here are all the changes between 1.9.2 and 1.9.3 https://github.com/modxcms/Login/compare/7a92ea9a793ff0be8e06775e77d0d1c44adc3bc0...8f6043404dcad627cc229422ff768a89f1091c0d

          Quote from: ocdcoder at May 14, 2017, 12:05 PM
          Nice to meet you, by the way. Did you take over the project from splittingred?

          No, I just have patched some annoying bugs. Maybe not good enough.
            • 39251
            • 53 Posts
            Ok, we reverted to 1.9.2 so hopefully it makes it clearer where things went weird. What I'm going to paste here is an absolute minimum snippet call, I know it needs other parameters, but this is just to demonstrate the validation. I'm also only going to include the HTML for a couple of the fields, not the entire form. There's nothing on it that would be affecting this.

            I see in the 1.9.2 readme it says to include validation in the field name, not in the snippet call. But this is following the RTFM online instructions, where it says, "Validators in Login follow the same syntax as FormIt Validators. You can use the methods described there to use them in your Login-based snippets."

            [[!Register? 
                &validate=`username:required` &username.vTextRequired=`Username is required.`]]
            ...
              <div class="field">
                <label for="username">Username</label>
                <input type="text" name="username" id="username" class="input" value="[[!+username]]" size="20" />
                [[!+error.username]]
              </div>
              <div class="field">
                <label for="email">Email Address</label>
                <input type="text" name="email" id="email" class="input" value="[[!+email]]" size="20" />
                [[!+error.email]]
              </div>


            In 1.9.2, if I submit this blank, bizarrely, I actually get this:
              <div class="field">
                <label for="username">Username</label>
                <input type="text" name="username" id="username" class="input" value="" size="20" />
                 <span class="error">Username is required.</span>
              </div>
              <div class="field">
                <label for="email">Email Address</label>
                <input type="text" name="email" id="email" class="input" value="" size="20" />
                <span class="error">Username is required.</span>
              </div>

            Bizarrely being it reporting the same error in both placeholders. (In all field error placeholders on the form besides the ones I included above except for password confirmation, to be completely accurate, even though they aren't marked as required.) If I change the snippet call to this, it displays the correct error for the email. (Now the password field is showing the email error instead, so I'd have to do something for it as well. But overall, it essentially works.)
            [[!Register? &validate=`username:required,email:required` 
                &username.vTextRequired=`Username is required.` 
                &email.vTextRequired=`Email Address is required.`]]

            So now upgrading back up to 1.9.3 (completely uninstalling 1.9.2 just in case), changing nothing else and submitting the blank form, I get this, no errors:
              <div class="field">
                <label for="username">Username</label>
                <input type="text" name="username" id="username" class="input" value="" size="20" />
                
              </div>
              <div class="field">
                <label for="email">Email Address</label>
                <input type="text" name="email" id="email" class="input" value="" size="20" />
                
              </div>

            So, I change the form to follow the instructions in the readme, and looking at the example chunk to make sure that the error placeholder hasn't changed, I still get no errors:
              <div class="field">
                <label for="username">Username</label>
                <input type="text" name="username:required" id="username" class="input" value="" size="20" />
                
              </div>
              <div class="field">
                <label for="email">Email Address</label>
                <input type="text" name="email:required" id="email" class="input" value="" size="20" />
                
              </div>

            So I change it all completely to just use the example chunk, lgnRegisterFormTpl. Same result, it's not even working with the code that comes with it.
                    <label for="username">Username
                        <span class="error"></span>
                    </label>
                    <input type="text" name="username:required:minLength=6" id="username" value="" />

            (I didn't include email since it's farther down the form this time, but same thing, no error.) I also tried it removing the FormIt-like code from the snippet and just calling [[!Register]], but still no errors.

            Sorry this is so long, but I wanted to be thorough. Also, I know it's not my call, but my preference would be for it all to work like FormIt. It was nice that the registration worked using the same parameters and same types of placeholders that I'm used to using with every other form I do. Given that the validation doesn't even work now with the included chunk, and it didn't look like the placeholder changes affected it, I'm not sure how this is supposed to work now.
              If there's a better way to do it, I'll find it.
              • 39251
              • 53 Posts
              Quote from: Jako at May 14, 2017, 02:49 PM

              Here are all the changes between 1.9.2 and 1.9.3 https://github.com/modxcms/Login/compare/7a92ea9a793ff0be8e06775e77d0d1c44adc3bc0...8f6043404dcad627cc229422ff768a89f1091c0d

              Oops, our posts crossed. I think that all took me longer to type up than it would have to read the entirety of the source code line-by-line. smiley Maybe this will answer my last comment, at least.

              Quote from: Jako at May 14, 2017, 02:49 PM
              Quote from: ocdcoder at May 14, 2017, 12:05 PM
              Nice to meet you, by the way. Did you take over the project from splittingred?

              No, I just have patched some annoying bugs. Maybe not good enough.

              Making the placeholders more consistent was definitely a step in the right direction, although I personally would have picked the same prefix for everything. (Unless maybe people tend to stick multiple snippets on the same page? But FormIt has a nice workaround for that.)

              Anyway, going to go read some Register code now. Thanks for the link. smiley
                If there's a better way to do it, I'll find it.
                • 39251
                • 53 Posts
                I see that you added loggedinResourceId and loggedoutResourceId as default properties where they weren't there before in Login, although it looks like it's still using the originals (loginResourceId and logoutResourceId) in most places except your new code. Was that intentional?

                I did figure out the issue with Register, though. Line 103 is adding the dot before error, so if you don't pass in a prefix, it's looking for [[!+.error.username]]. Which works, except now it's displaying the error twice. But, um, progress? Although if I take out the FormIt-style &username.vTextRequired=`Username is required.` part, it's picking up NOT the next one I have defined, for the email, but the last one for the password confirmation, and I'm getting this:
                  <div class="field">
                    <label for="username">Username</label>
                    <input type="text" name="username" id="username" class="input" value="" size="20" />
                     <span class="error">This field is required.</span> <span class="error">You must confirm your password.</span>
                  </div>

                Oh, but if I do pass in a placeholder, it works perfectly! So ok, definitely progress. (And I passed in "fi." Please be kind and don't remove the FormIt-type validation that is there, I really love that parts of this act like FormIt, it makes it so much easier to work with. smiley)

                I have to commend you, this is quite a job to take on. I'm confusing the heck out of myself just trying to double-check everything enough to make sure I'm (hopefully) accurate with what I post here... I haven't even looked at any of the rest of the snippets yet.
                  If there's a better way to do it, I'll find it.
                  • 13428 ☆ A M B ☆
                  • 1,031 Posts
                  Please try the changes in this commit https://github.com/Jako/Login/commit/0262d52100ed4af4f69f2e2b73c178b46a67f49e . They should fix the '.error' placeholder issue.
                    • 3749
                    • 24,544 Posts
                    Thanks for the kind words. I've never had the nerve to mess with the extremely convoluted Login code.

                    Quite a while ago, I wrote the Subscribe extra, which provides a wrapper around the Register snippet. IIRC, I added JavaScript validation so the form doesn't get submitted unless the fields are valid, possibly because I could never get the built-in validation to work reliably.

                    You're welcome to use the Subscribe validation code if it will help.

                    https://github.com/BobRay/Subscribe/blob/b944207abe347ba4038a762fc501f1541cdf97b3/assets/components/subscribe/js/subscribe.js
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 13428 ☆ A M B ☆
                      • 1,031 Posts
                      Quote from: ocdcoder at May 14, 2017, 04:02 PM
                      I see that you added loggedinResourceId and loggedoutResourceId as default properties where they weren't there before in Login, although it looks like it's still using the originals (loginResourceId and logoutResourceId) in most places except your new code. Was that intentional?

                      The loggedinResourceId/loggedoutResourceId redirect not logged or logged users to the according resources on every request. Not only on successfull login/logout as loginResourceId/logoutResourceId. The new parameters were introduced to maintain backwards compatibility. [ed. note: Jako last edited this post 9 years, 4 months ago.]