Jump to content

Login/Register for front end page access bouncing user back to login page despite being logged in?


hollyvalero
 Share

Recommended Posts

1. using LoginRegister for a simple username/password to view a demo course.

Vanilla installation:
 $modules->get('LoginRegister')->execute()  

Login url is /login/ using login template that anyone can see -> and that's working.

when not logged in, you see the form.  When logged in you see a logout link and copy that shows up upon logging in. -> that's working


2. There is 1 template: demos (for the actual videos)  - viewable for login-register role, but not for guest.

I have set the template to redirect to: /login/ if you are not logged in.
when I go to the demo URL not logged in, I am bumped to /login/ -> that's working.
http://test2.hollycodes.net/shop/view-demo-training-videos/security-awareness-for-it-professionals-demo/

 

3.   the guest role can page-view all except demos  and login-register role can see all pages

 
4. When logged in as super user, I see all pages correctly 

5. HOWEVER

If I go here: http://test2.hollycodes.net/shop/view-demo-training-videos/ 
and follow the link to login: http://test2.hollycodes.net/login/
and enter

frank
daypass123

I get Welcome frank...and the welcome copy and a link to go to the courses...

But when I click that course link to the demos template, it bounces me back to the login page, despite being logged in. 
----> What am I doing wrong? <------


a. I was originally going to use login/register pro, but it seemed like overkill for a simple u/p combo...
b. Then I tried to automatically bounce people back to the course list after logging in:

<?php
if($user->isLoggedin() && !$input->get('profile') && !$input->get('logout')) {
  $session->redirect('/shop/view-demo-training-videos/'); 
} else {
  // let the LoginRegister module have control
  echo $modules->get('LoginRegister')->execute(); 
}

but the login just cycled between /shop/view-demo-training-videos/ and /login/ and melted down.  Which seems like  I should change it in the template, but that just makes no sense...

 

----> What am I doing wrong? <------

I uninstalled login/register pro, there's nothing in the error logs...
tried it in a fresh browser - same issues

What dumb thing am I missing here?

Screen Shot 2020-02-06 at 1.57.56 PM.png

Link to comment
Share on other sites

I'm not sure what the missing piece of the puzzle is. But I managed to put together a similar setup in a few minutes, and it all works as expected. Perhaps you can compare your setup with mine and you'll find out what you're missing.

Here's what I did:

Create a role "member"

Create a login page with template "login". In that tpl I basically have

if($user->isLoggedin() && !$input->get('profile') && !$input->get('logout')) {
    $goto = $pages->get(23115)->url; // the restricted page
    $session->redirect($goto);
} else {
    echo $modules->get('LoginRegister')->execute();
}

I'm too tired atm to write the rest all down, but here are screenshots.

1920443342_Screenshot_2020-02-06EditTemplateRestricted(restricted)pwbigtest.thumb.png.a165132097ee95efac6ede7bf91531a9.png

178836828_Screenshot_2020-02-06EditTemplateloginpwbigtest.png.f701dfa52f5349a12f09e1394ab5cd7b.png

1298318783_Screenshot_2020-02-06Roleslogin-registerpwbigtest.png.e5144d0bfb7584493569520e601614a3.png

1987550897_Screenshot_2020-02-06Usersgonzopwbigtest.png.7dfd41ef44025aae7c409d2b27ff6aa4.png

494375334_Screenshot_2020-02-06Rolesmemberpwbigtest.png.85024b111220db08c7122821f83a5580.png

I'm not sure if a separate role than login-register is really required, but it's likely that login-register is going to be used by more than one user-type, and I guess it's good practice to handle permission stuff as granular as possible, to avoid headaches down the road.

Screenshot_2020-02-06 Pages • ProcessWire • pwbig test.png

  • Like 1
Link to comment
Share on other sites

First of all, thank you so much for taking the time to slog through the set up - and all the screen snaps. 

I switched the url redirect "/login/" to the page ID to see if that might help, but I think what I did wrong was that --> on the login page template, the editor role could view and EDIT<--. Not just view. All the rest looked the same as far as the set up.

I agree that it's a better practice to create a new role instead of just using login-register.  Those changes seem to have fixed it... and the redirect($goto) is working too.  I assume maybe the login template can be only view access.

Let me just add that bit of wisdom to my "when the bad thing happened" file. ?

THANK YOU so much!! In the meantime I looked at Login Register Pro ... hopefully can offer either.

 

h

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...