We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54592
    • 7 Posts
    Hey,

    i want to make a document, where a member can login. For now, my document appear like this:

    [[!Login? &loginTpl=`lgnLoginTpl` &logoutTpl=`lgnLogoutTpl` &errTpl=`lgnErrTpl` &loginResourceId=`1` &logoutResourceId=`1`]]
    
    <div class="loginForm">
        <div class="loginMessage">[[+errors]]</div>
        <div class="loginLogin">
          <form action="[[~[[*id]]]]" method="post">
          <fieldset>
                <input type="hidden" name="login_context" value="mgr" />
                <input type="hidden" name="modahsh" value="{$modahsh|default}" />
                <input type="hidden" name="returnUrl" value="{$returnUrl}" />
    
           <legend class="loginLegend">[[+actionMsg]]</legend>
            <div class="form-group"><Input id="modx-login-username" type="text" name="username" placeholder="User ID" class="form-control" aria-required="true" required style="width:50%;" /></div>
            <div class="form-group"><input id="modx-login-password" type="password" name="password" placeholder="Password" class="form-control" aria-required="true" required style="width:50%;" /></div>
            <div class="form-group"><button class="btn btn-primary btn-block" type="submit" style="width:20%;">Log In</button></div>
          </fieldset>
          </form>    
        </div>
    </div>
    


    I dont know if i had any failure in this code?! I dont really understand this Login infrastructure of modx so i really helpless at the moment :/

    Document access for document X is granted for user X. I have done this with Ressource-Group, create a user and set the permission (role: Member "9999") for Kontext Web. So why this is not function? I'm sure i missed some code in the Login document, but i have no clue what?

    --> my idea was..
    I want that a member can Log-in and after this process he get his member page i've connected with Ressource-Group and User. The member should also have the Option to Logout with a Logout link. <a href="/security/logout"></a>

    Hope anyone can help me smiley

    This question has been answered by arri_amira. See the first response.

      • 3749
      • 24,544 Posts
      It seems like what you're doing should work, but another way to do it is to have one dedicated login page for all users, then create a User Setting for each user called user_page containing the ID of the user's page.

      In the login tag, do this:

      [[!Login? &loginResourceId=[[++user_page]] ]]


      That will redirect the user to their own page after a successful login if you have the permissions set correctly.




        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
        • 54592
        • 7 Posts
        Quote from: BobRay at Sep 23, 2018, 03:21 AM
        It seems like what you're doing should work, but another way to do it is to have one dedicated login page for all users, then create a User Setting for each user called user_page containing the ID of the user's page.

        In the login tag, do this:

        [[!Login? &loginResourceId=[[++user_page]] ]]


        That will redirect the user to their own page after a successful login if you have the permissions set correctly.

        It should work, but it doesnt. It seem's like modx cant do anything with this script in the document. When i Login with user 'demo' and Password 'demo' it reload the page. I paste the [[!Login ]] code in there. So usually modx should redirect me to the user page ?

        EDIT: i changed this from value="mgr" to "web", 'cause i want the user not to be in the manager.
                    <input type="hidden" name="login_context" value="web" />
        
        [ed. note: arri_amira last edited this post 5 years, 7 months ago.]
          • 54592
          • 7 Posts
          Quote from: arri_amira at Sep 23, 2018, 08:57 AM
          I found this in MODX Docs. It matches my proplem.

          Login errors are not displayed
          If you fingermash the keyboard with a non-existent username and try to login, sometimes you don't see any errors displayed.

          I allways dont see any errors :,D The site is still reloading after i log-in with a user or non-user.
          But how i get this script to work? I followed the tutorial in the docs..
            • 54592
            • 7 Posts
            So after a while, user can log-in on their account.. but simply only on their account…?!

            i added this
             [[!Login? &loginResourceId=[[++user_page]] ]] 

            to the chunk that be load a Login form.

            In user Settings i've create a new key called "user_page" with value "10" for user demo.. - 10 is the id of the user page..

            All fine! smiley But!!! The user "demo" doesnt redirected to his user page - why huh

            Anyone can explain this issue?
              • 3749
              • 24,544 Posts
              Is the user page published?

              Try deleting all files in the core/cache directory.
                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
              • discuss.answer
                • 54592
                • 7 Posts
                In the last few hours, i had found a solution.


                Is the user page published?

                Try deleting all files in the core/cache directory.

                It is! I deleted the cache dir's too.
                Now, here is the solution i found. When the user Login with the followed script (with login addon):
                [[!Login? &tplType=`modChunk` &loginTpl=`myLoginChunk` &loginResourceId=`13` ]]
                
                <!-- BUT NOT THIS BELOW -->
                
                [[!Login? &tplType=`modChunk` &loginTpl=`myLoginChunk` &loginResourceId=`[[++user_page]]` ]]
                

                MODX cant load in a Login snippet a key with brackets, or the addon cant keep up with brackets in brackets. So if u want to handle this proplem, u must create a member page as a succesfull "after login" Landing page. A example is followed:
                <!-- THIS IS THE SCRIPT PLACED IN THE LANDING PAGE -->
                
                <a href="?id=[[++user_page]]" class="btn btn-primary">Take me to the Download</a>
                


                U can see, here a user specific key, that can handled with. [[++user_page]] has a value of 10. The number is the same as the page id. On this, i called "after Login Landing page", MODX (or the addon, i dont know..) can understand the key, i called in the script.

                So u dont create 5 site or more for login, dont worry..
                U have only 2 login specific sites. The landing page has a specific permission, so non-loggedin users cant see and interact with this id/document.
                The 3rd site is u're Member or in my case a Download Page, where i can give my customer's my Filmed material or Picture's from events.

                Logout is also easy as simple!
                <a href="[[~11? &service=`logout`]]" title="Logout" class="forgot">Logout</a>
                

                Just put this in u'r document anywhere. BUT be advised! Dont forget to point the document with the login snippet in it!
                So in my case i pointed the Login snippet on document 11. This char "~" mean the "?id=".


                So u have:

                • Login Page - for all users (pointed to id13)
                • Landing Page - only for logged-in users (id13, pointed to user's page "[[++user_page]]")
                • Member Page - only for logged-in users (have the same id, as in the user key specified)

                I hope i can help other's with this solution. Unfortunately, u cant only set up a Login page and a member page in this case.
                So this case is now solved! Thx to BobRay for the Support wink This helped a much! So Thanks a lot. smiley
                  • 3749
                  • 24,544 Posts
                  I'm glad you got it sorted.

                  It took me a minute, but I realized why my original idea won't work and yours does (duh). It's not the nested placeholders. Since the user hasn't successfully logged in, MODX doesn't know who the user is and so can't fill in the ++user_page placeholder in the login form.

                  If you want to send the user directly to their page, you should be able to put this snippet on your landing page:

                  [[!ForwardToUserPage]]  


                  /* ForwardToUserPage Snippet */
                  $url = $modx->makeUrl([[++user_page]], "", "", "full");
                  $modx->sendRedirect($url);
                  
                  [ed. note: BobRay last edited this post 5 years, 6 months ago.]
                    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
                    • 54592
                    • 7 Posts
                    Thanks this is also helpfull! smiley

                    I solved this for now as simple as possible for me laugh
                    <p style="padding:2pt;font-size:12pt;color:white;width:40%;height:75pt;background-color:rgb(200,200,200);">[[++user_comment]] </p>
                    

                    So the user see a comment, this was my idea for a notification to the user.
                    For example, when i added Special effects to a film/video, and i would tell this my customer, then i write in the value a notification / comment.

                    I think i integrate this snippet for prompting some class of customer directly to his page.

                    So thanks for the tip smiley
                      • 3749
                      • 24,544 Posts
                      You could maybe put the comment somewhere on the user's page.
                        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