We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20865
    • 30 Posts
    Hello everyone.
    Is there any ready solutions for this one? Or can you tell my any idea about doing this?
    All I need - to have synchronized base of users on my site and forum, and easy access to some fields(like usergroup, name).

    I think to just cut all of login.login funcs and change links like "register, profile, forgot password" on a similar on a forum and write a custom authorization that will place all usefull info in session.

    I have choosen this way because I don’t want to rewrite all funcs of Login in order to send requests to set or insert some fields and have two synchronized tables(it can be better solution but it is a time-wastage for me)
      • 20865
      • 30 Posts
      seems like nobody wants to reply.

      My custom authorization is written and works(was busy).
      Please tell my what exactly sessions must be filled in order to work normally with DBAPI classes?
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        I think you’ll need to use a plugin on the OnBeforeWebLogin system event, to override the login procedure: http://rtfm.modx.com/display/revolution20/OnBeforeWebLogin

        That said, that’s as much as I know about the subject.


        Susan wrote an article on SSO with Vanilla, perhaps it can help you. http://sottwell.com/article-vanilla.html


        ( As you’ve noticed, there’s not a lot of people atm who can help on this subject, so if you end up finding a solution it would be greatly appreciated if you could post it here to help others wanting to do the same! )
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 20865
          • 30 Posts
          Wow, a lot of classes ) cool, haven’t seen them before.
          My authorization isn’t a solution at all ) But if you insist ))
          It was a PHP, and just was reworked.
          <?php
          if (isset($_POST['send']))
          {
            $connectDB = mysql_connect('arguments'); # fill it
            $selctDB= mysql_select_db('arguments', $connectDB); #fill it
            if($selctDB)
            {
              $def_user = mysql_real_escape_string ($_POST['user']);
              $def_user = strip_tags($def_user);
              $def_user = htmlspecialchars($def_user);
              $def_user = stripslashes($def_user);
              $def_user = addslashes($def_user);
              $_POST['user'] = $def_user;
              $def_password = mysql_real_escape_string ($_POST['password']);
              $def_password = strip_tags($def_password);
              $def_password = htmlspecialchars($def_password);
              $def_password = stripslashes($def_password);
              $def_password = addslashes($def_password);
              $_POST['password'] = $def_password;
              $stmt = mysql_query("SELECT name, member_group_id, members_pass_salt, members_pass_hash FROM members WHERE name='".$_POST['user']."'"); #standart IPB things
              $row=mysql_fetch_array($stmt);
              $password =  md5(md5($row['members_pass_salt']).md5($_POST['password']));
                if ($password == $row['members_pass_hash'])
                {
                  session_start();
                  $_SESSION['CustomLogin'] = TRUE;
                  $_SESSION['CustomUserName'] = $row['name']; #setting up session for further things
                  $_SESSION['CustomGroupID'] = $row['member_group_id'];
                  $id = $modx->documentIdentifier;
                  $url = $modx->makeUrl($id);
                  $modx->sendRedirect($url);
                }
              else
              {
           $modx->setPlaceholder('errors','Wrong username or password');
              }
            }
          }​
          

          Chunk for it :
          <div class="hot-block">
          
                  <i class="cr c-tl"></i>
          
                  <h2><span>Enter the system</span></h2>
          
                  <dl class="hot-block-i">
                 <form action="[[~[[*id]]]]" method="post" name="loginform" id="form2">
                    <table align="center" width="100%">
                        <tr>
                          <td align="center" colspan="2"><div class="loginMessage"><font color="red">[[+errors]]</font></div></td>
                        </tr>
                          <tr>
                             <label class="loginUsernameLabel">
                               <td>Логин:</td>
                               <td><input class="loginUsername" type="text" name="user" /></td>
                             </label>
                          </tr>
                          <tr>
                             <label class="loginPasswordLabel">
                               <td>Пароль:</td>
                               <td><input class="loginPassword" type="password" name="password" /></td>
                             </label>
                          </tr>
                          <tr align="center">
                             <td>
          <input type="hidden" name="send" value="true" /><input type="submit" name="submit" value="Enter" />
                            </td>
                            <td><a href="ipb/index.php?app=core&module=global&section=lostpass">ForgotPassword?</a></td>
                          </tr>
                          <tr>
                            <td colspan="2"><a href="ipb/index.php?app=core&module=global&section=register">Register</a></td>
                          </tr>                
                    </table>
                  </form>
                  </dl>
                  <i class="b">
                    <i class="cr c-bl"></i>
                    <i class="cr c-br"></i>
                  </i>
          </div>
          [[!CustomLogin]]​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
          

          Snippet that calls login or logout form :

          #calling [[!CheckAuth ? &is=`lgnLogoutTpl` &not=`CustomLogin`]]
          <?php
          if($_SESSION['CustomLogin'])
            {
          
                  $output = $modx->parseChunk($is);
              }
              else
              {
             $output = $modx->parseChunk($not);
              }
            return $output;​
          

          LogOutTpl
          [[!LogOutButton]]
          <div class="hot-block">
          
                  <i class="cr c-tl"></i>
          
                  <h2><span>Hello, [[+CustomUserName]]</span></h2>
          
            <dl class="hot-block-i">
                  <table class="hot-block-table">
                    <tr>
                      <td>Группа: [[+CustomGroupID]]</td>
                    </tr>      
                      <td><a href="ipb">Forum</a></td>
                    </tr> 
                    <tr>
                      <td><a href="[[~[[*id]]]]?logout=1">Exit</a></td>
                    </tr> 
                  </table>
                    <br style="clear:both"/>
                  </dl>
          
                  <i class="b">
          
                    <i class="cr c-bl"></i>
          
                    <i class="cr c-br"></i>
          
                  </i>
          </div>​
          

          LogOutButton
          <?php
          $id = $modx->documentIdentifier;
          $url = $modx->makeUrl($id);
          if (isset($_GET['logout']))
          {
            session_start();
            $_SESSION['CustomLogin'] = NULL;
            $_SESSION['CustomUserName'] = NULL;
            $_SESSION['CustomGroupID'] = NULL;
            $modx->sendRedirect($url);
          }
          $modx->setPlaceholder('CustomUserName', $_SESSION['CustomUserName']);
          $modx->setPlaceholder('CustomGroupID', $_SESSION['CustomGroupID']);​
          

          Also I have reworked a LOT of snippets that are using users or checking authorization in order to make this solution work.
          PS it ISN’T a good idea to use this. It is just for working, but in this way it is cutting a LOT of functions you might want to use. I just don’t know how to manage users right and it is really hard to understand how Login.Login works(there are a lot of functions that I don’t know).