We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    This is an auto-generated topic for Login 1.4.0-rc2 by splittingred.

    Brief Description:

    Loads a simple login/logout form, with password retrieval functionality and a register form snippet.
    New in 1.4.0

    • [li][[#27]] Fixed issue with activationEmail always overriding normal email
    • [[#29]] Added loginResourceParams, logoutResourceParams, which allows attaching REQUEST parameters to login/logout redirection URLs
    • [[#26]],[[#14]] Added activationEmail property for better handling of middle men in activation steps
    • [/li]
    • Added changelog to build


    New in 1.3.2

    • [[#25]] Added isLoggedIn snippet for checking auth status
    • [[#24]] Fixed issue where inactive user could re-register
    • Fixed issue with embedded chunk type display
    • Fixed issue with redirects and non-FURLs on Register snippet

    See the Official Documentation here:
    http://rftm.modx.com/display/ADDON/Login
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 11055 ☆ A M B ☆
      • 3,112 Posts
      so the loginResourceParams has to be in JSON format?

      These were my old code:
      The snippet:
      <?php
      
      $appendUrl = array();
      if (isset($_GET)) {
          foreach ($_GET as $k => $v) {
              if ($k == 'board' || $k == 'thread' || $k == 'post'){
                  $appendUrl[] = $k . '=' . $modx->sanitizeString($v);
              }
          }
      }
      /* private option */
      $modx->setOption('discuss.appendUrl', $appendUrl);
      


      The class:

      <?php
      
          function __construct(modX &$modx, array $config = array()) {
              $this->appendUrl = $this->modx->getOption('discuss.appendUrl');
          }
      
      
          public function sign($sign) {
              switch ($sign) {
                  case 'in':
                      if ($this->modx->user->isAuthenticated()) {
                          $filteredAppendUrl = array_diff($this->appendUrl, array('sign=in'));
                          $filteredAppendUrlString = implode('&', $filteredAppendUrl);
                          $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->get('id'), null, $filteredAppendUrlString));
                      }
      
                      $signInTpl = $this->modx->getOption('discuss.dislogin_chunk', $scriptProperties, 'disLogin');
                      $properties = array();
                      $properties['discuss.loginAction'] = '';
                      $properties['discuss.loginResourceId'] = $this->modx->resource->get('id');
                      $properties['discuss.core_path'] = $this->config['corePath'];
                      $loginResourceIdQuery = $this->modx->getOption('discuss.loginResourceIdQuery', $scriptProperties, $appendUrlString);
                      $properties['discuss.loginResourceIdQuery'] = $loginResourceIdQuery;
                      $properties['discuss.registerLink'] = $this->modx->makeUrl($this->modx->resource->get('id'), null, 'sign=reg');
                      $output = $this->getChunk($signInTpl, $properties);
                      break;
              }
          }
      


      Snippet call:
      
      [[!Login?
      &tplType=`file`
      &loginTpl=`[[+discuss.core_path]]elements/chunks/dislgnlogintpl.chunk.tpl`
      &logoutTpl=`[[+discuss.core_path]]elements/chunks/dislgnlogouttpl.chunk.tpl`
      &loginResourceId=`[[+discuss.loginResourceId]]`
      &loginResourceIdQuery=`[[+discuss.loginResourceIdQuery]]`
      ]]
      


      It was the ’loginResourceIdQuery’ that I proposed.
      So how to use loginResourceParams now?
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 11055 ☆ A M B ☆
        • 3,112 Posts
        I tried this:
        <?php
        $appendUrlJSON = null;
        if (!empty($this->appendUrl)) {
            // This only to convert the original array [0] => "board=1" to 'board' => '1'
            $appendUrlStringKeyArray = array();
            foreach ($this->appendUrl as $k => $v) {
                $xpldVals = @explode('=', $this->appendUrl[$k]);
                $appendUrlStringKeyArray[$xpldVals[0]] = $xpldVals[1];
            }
            $appendUrlJSON = $this->modx->toJSON($appendUrlStringKeyArray);
        }
        
        $loginResourceParams = $this->modx->getOption('discuss.loginResourceParams', $scriptProperties, $appendUrlJSON);
        $properties['discuss.loginResourceParams'] = $loginResourceParams;
        
        

        Change snippet:
        [[!Login?
        &tplType=`file`
        &loginTpl=`[[+discuss.core_path]]elements/chunks/dislgnlogintpl.chunk.tpl`
        &logoutTpl=`[[+discuss.core_path]]elements/chunks/dislgnlogouttpl.chunk.tpl`
        &loginResourceId=`[[+discuss.loginResourceId]]`
        &loginResourceParams=`[[+discuss.loginResourceParams]]`
        ]]
        


        And the redirect seems unexpected: hxxp://localhost/modx-revo-discuss/index.php?id=22&amp;board=1
        I believe you still need the htmlspecialchars_decode for the redirect.
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.