ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Template access redirect odd behavior

April 06, 2012 5:18pm

Subscribe [2]
  • #1 / Apr 06, 2012 5:18pm

    fram

    6 posts

    I set up an entire template group to be accessible by a specific user group and to redirect other users to a page on the site.

    The users member of the group can visit the page just fine, but when I try to access the page with a user not within the allowed group the user is not redirected correctly and it’s shown a page.

    I tried everything on the templates and settings on the CP and finally I decided to take a crack at the template source code.
    It looks the bounce template is hardcoded to a numeric id: 3 in template.php lines 2189 .

    Please check the line under the comment starting with FRAM.

    // Is the current user allowed to view this template?
      if ($query->row('enable_http_auth') != 'y' && $query->row('no_auth_bounce')  != '')
      {
       $this->log_item("Determining Template Access Privileges");
       
       $this->EE->db->select('COUNT(*) as count');
       $this->EE->db->where('template_id', $query->row('template_id'));
       $this->EE->db->where('member_group', $this->EE->session->userdata('group_id'));
       $result = $this->EE->db->get('template_no_access');
       if ($result->row('count') > 0)
       { 
        if ($this->depth > 0)
        {
         return '';
        }
       
        $query = $this->EE->db->select('a.template_id, a.template_data,
         a.template_name, a.template_type, a.edit_date,
         a.save_template_file, a.cache, a.refresh, a.hits,
         a.allow_php, a.php_parse_location, b.group_name')
         ->from('templates a')
         ->join('template_groups b', 'a.group_id = b.group_id')
    // FRAM Comment this looks quite wrong ...
         ->where('template_id', 3)
         ->get();
       }
      }

    Shouldn’t that value set to $query->row(‘no_auth_bounce’) changing the query code fixes my problem:

    $query = $this->EE->db->select('a.template_id, a.template_data,
         a.template_name, a.template_type, a.edit_date,
         a.save_template_file, a.cache, a.refresh, a.hits,
         a.allow_php, a.php_parse_location, b.group_name')
         ->from('templates a')
         ->join('template_groups b', 'a.group_id = b.group_id')
    // FRAM Comment is the following code correct ?
         ->where('template_id', $query->row('no_auth_bounce'))
         ->get();

    Please let me know what you think.

    FraM

  • #2 / Apr 06, 2012 5:42pm

    glenndavisgroup

    436 posts

    Hi fram,

    What version of EE are you using? I just checked my EE 2.4 and I have the correct code in my file. No hard coded number in there?

    Mike

  • #3 / Apr 06, 2012 5:55pm

    fram

    6 posts

    I just re-downloaded ExpressioneEngine under my purchases and the current version is affected by the the above problem.

    FraM

  • #4 / Apr 06, 2012 6:06pm

    fram

    6 posts

    To be sure that we are looking at the same file this is the path in the ExpressionEngine zip file:
    system/expressionengine/libraries/Template.php

    FraM

  • #5 / Apr 06, 2012 6:23pm

    glenndavisgroup

    436 posts

    That’s the exact file I was looking at as well. I think I downloaded my EE 2.4 zip about 2 months ago can’t remember exactly. Not sure why it would have been changed but it looks like it has.

    Can anyone from EE confirm?

    Thank you,

    Mike

  • #6 / Apr 07, 2012 1:17am

    fram

    6 posts

    I found the link to the bug report
    https://support.ellislab.com/bugs/detail/17402

    Wish I could have found this sooner 😉

    FraM

  • #7 / Apr 09, 2012 11:31am

    Shane Eckert

    7174 posts

    Hey fram,

    I am sorry to hear you are running into this bug.

    I suggest subscribing to the bug to stay up on the updates by leaving a comment.

    Is there anything else I can do for you? Any questions?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases