Login Design doesn't recognise a user as Logged In


(Emily) #1

Matrix Version: 5.5.2

When a user is logged in but doesn’t have read access, the Login Design isn’t treating them as Logged In in terms of displaying my “Logout” portion of the Login Design Area, to say "You are currently logged in as: … " - It instead displays the Username and Password Fields.

However, when I use a Show_If area of Logged In condition, it DOES evaluate as True / Logged in, and then show the “THEN” portion (rather than “ELSE”). However, when the THEN portion is set to print the (previously defined in the Design File but print=“no”) Login Design Area, it will opt to print the LOGIN not the LOGOUT portion of that Design Area…

I saw another post with a similar issue from last year, but it was referring to a bug in an earlier version of Matrix, and pointed to Road Map - which I do not have access to view. I assume that the bug would have been patched in my current version of 5.5.2.

Here are my Design Area codes:

If the User is logged in, then the show_if area prints this Design Area:

<MySource_AREA id_name="logged_in" design_area="login_form" print="no">
  <li class="logged-in-block">
    <MySource_PRINT var="system_messages" />
    <MySource_LOGIN_SECTION>
      Not currently logged in. This should not be printing, but does.
    </MySource_LOGIN_SECTION>
    <MySource_LOGOUT_SECTION>
      <MySource_PRINT var="form_open" />
        Currently logged in as: 
         <MySource_PRINT id_name="__global__" var="current_user" default="[Not Logged In]" attr="name" />
         <MySource_PRINT var="submit_button" value="Logout" class="sq-backend-data btn btn--primary col-md-3 align-baseline" />
       <MySource_PRINT var="form_close" />
     </MySource_LOGOUT_SECTION>
   </li>
</MySource_AREA>

Is the user logged in? If so, print the logged_in design area (above). Else, print a Login pop-out lightbox so they can login or create an account.

            <MySource_AREA id_name="public_user" design_area="show_if">
              <MySource_SET name="condition" value="logged_in" />
              <MySource_THEN>
                <MySource_PRINT id_name="logged_in"/>
              </MySource_THEN>
              <MySource_ELSE>
                <li>
                  <div class="modal-instance">
                    <a href="#" class="modal-trigger">Login</a>
                    <div class="modal-container">
                      <div class="modal-content section-modal">
                        <section class="unpad ">
                          <div class="container">
                            <div class="row justify-content-center">
                              <div class="col-md-6">
                                <div class="boxed boxed--lg bg--white text-center feature">
                                  <div class="modal-close modal-close-cross"></div>
                                  <h3>Login to Your Account</h3>
                                  <div class="feature__body">
                                    <MySource_PRINT id_name="login"/>
                                    <span class="type--fine-print block">
                                      Don't have an account yet? 
                                      <a href="./?a=50250">Create account</a>
                                    </span>
                                    <span class="type--fine-print block">
                                      Forgot your username or password?
                                      <a href="./?a=42388">Recover account</a>
                                    </span>
                                  </div>
                                </div>
                              </div>
                            </div><!--end of row-->
                          </div><!--end of container-->
                        </section>
                      </div>
                    </div>
                  </div>
                </li>
              </MySource_ELSE>
            </MySource_AREA>    

I use the exact same code in my normal Design File too, and it works without fault.
And if the user truely is not logged in, then it works fine because the Show_IF ELSE portion displays.

(Initially I did not have the LOGIN section of the Login Design Area in the code, but placed it in to help identify what was happening with the Login Design Area not printing the LOGOUT portion.)

Anyone else come across this? Any solutions?


(Emily) #2

No one else had this problem before, or can see a flaw in my setup/concept? :confused:

  • Emily

(Bart Banda) #3

Hey Emily, not sure why it’s not working, haven’t had a chance to look closer to the implementation. But maybe you could simplify some of this by using keywords?

For example for the users who are logged in but don’t have access, you could maybe do something with the %asset_has_read/write/admin_access% keyword?

A boolean value based on if the user has a specific type of access to an asset. For example, %frontend_asset_has_write_access%, will print either

1

if the current user has Write Access to the current frontend asset, or

0

if they don’t.


(Emily) #4

Hi Bart,

I hadn’t considered using the _has_read_access keyword, good food for thought. Not sure if it would fix the problem though, because users can be logged in but NOT have read access - in which I would like to show them different text than if they are not logged in at all. I think that is why I was using a Show_If area (to check if they are logged in) and Login_form Design Areas. (A bit hard to remember, as I haven’t worked on this since September due to no new ideas on fixing it).

Anyone who sees this Login Design doesn’t have read access to the page anyway.


(Bart Banda) #5

So you could use a combination of multiple keywords then, something like:

%begin_frontend_asset_has_write_access%
   //user is logged in and has write access
%else_begin_globals_user_is_logged_in%
  //user is logged in but only has read access
%else_%
   //user is not logged in at all
%end_%

Would something like that work/help?


(Emily) #6

It’s a Login Design, so it won’t be displayed to users who have read access.
I need to distinguish between:

  1. Logged in, but NO read access
  2. NOT logged in (and no read access)

(John gill) #7

I think you need the last part of Bart’s conditional keyword included in the Login Design via a nest_content area.

Testing with the login design

<title>test login design</title>
<MySource_area id_name="loginchecker" design_area="nest_content"/>

<MySource_AREA id_name="login_form" design_area="login_form">
    <MySource_LOGIN_SECTION>
        <MySource_SET name="forward_www_vars"    value="true" />
        <MySource_PRINT var="form_open" />
        <MySource_PRINT var="login_message" />
        Currently logged in as: <MySource_PRINT id_name="__global__" var="current_user" default="[Not logged in]" attr="name" />
        <MySource_PRINT var="system_messages" />
        <MySource_PRINT var="username_box" size="10" class="sq-data" required="required" autofocus="autofocus"/>
        <MySource_PRINT var="password_box" size="10" class="sq-data" required="required" autocomplete="off"/>
        <MySource_PRINT var="submit_button" value="Login" class="sq-data" />
        <MySource_PRINT var="form_close" />
    </MySource_LOGIN_SECTION>
</MySource_AREA>

Create a customisation, and add a new Standard Page as loginchecker area, containing

<pre>
%begin_globals_user_is_logged_in%
  user is logged in
%else_%
   user is not logged in at all
%end_%
</pre>

Then open two windows - one not logged in, and one logged in as a user with no permissions on the site that has the login design

image

I’m not sure if it would be possible without the nest_content area to drop into keyword-world.