Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[Pagebuilder] User Login Conundrum

Quote Reply
[Pagebuilder] User Login Conundrum
Background

We have set up a navigation bar to include this:
Code:
<%if Username%>
<A HREF="<%db_cgi_url%>/page.cgi?page=Users&user=<%Username%>">Personal Page</A> /
<A HREF="<%db_cgi_url%>/user.cgi?logout=1&d=0">Logout</A>
<%else%>
<A HREF="<%db_cgi_url%>/user.cgi">Login</A> /
<A HREF="<%db_cgi_url%>/user.cgi?logout=1">Logout</A>
<%endif%>

The Pagebuilder User pages are dynamic-only and restricted to Registered Users.

Dynamic mode is an option available to users after they have logged in, so if Username has a value, the user must be logged in, and be browsing in dynamic mode -- page.cgi?page=Users&user=<%Username%> opens a Pagebuilder page with information and links to everything the user can do.

The problem is how to do the same thing in static pages -- how to generate a 'Users' link with no argument (page.cgi?page=Users) that will
* Open the correct (dynamic) Pagebuilder User page if the user is logged in.
* Open the login page if the the user is not logged in.

Right now, this is what happens when page.cgi?page=Users has no argument ...
* If the user is logged in, we get an error "No page identification specified"
* If the user is not logged in, it opens the login page, but after submitting the form, the user is still not logged in, even though LSQL creates a new session.


Hoped-for Outcome

Static page navigation bar that looks like this ...
Code:
... Users / Logout ...
... a single button for logging in, or opening the personal user page if already logged in.


What we have tried

We created a dummy user called null, and put this in our static navigation bar ...
Code:
<A HREF="<%db_cgi_url%>/page.cgi?page=Users&user=null">Users</A> /
<A HREF="<%db_cgi_url%>/user.cgi?logout=1">Logout</A>
That allows logged-in users to get to their own personal pages, but it doesn't solve the second problem -- they can't actually log in that way.

The alternative static navigation bar ...
Code:
<A HREF="<%db_cgi_url%>/page.cgi?page=Users&user=null">Users</A> /
<A HREF="<%db_cgi_url%>/user.cgi">Login</A> /
<A HREF="<%db_cgi_url%>/user.cgi?logout=1">Logout</A>
... would be unthinkably bad usability.

Perhaps we should be thinking about an intermediate (server-side) step, so that the 'Users' button would either pass Username to page.cgi?page=Users, or if there were no Username, go straight to the login page.

My mind has gone blank on this one. Perhaps somebody else has already solved it?


A closely-related theme

Our login_success page has a link to the Pagebuilder user page. We would prefer to go straight to the user page. Is this possible?
Quote Reply
Re: [YoYoYoYo] [Pagebuilder] User Login Conundrum In reply to
What you could do to solve the 'User Personal Page' problem is the following:

1) Download the latest version of the plugin (contains some changes necessary for the steps below).
2) create a 'simple' page 'user_personal_page', which is only accessible for registered users.
3) on this page, put a the following tag that fetches the user information you might want

<%Plugins::PageBuilder::Tools::get_user_tags()%>

3) the navigation bar now just links to page.cgi?page=user_personal_page;
When a user is loggged in, they will get their information, if not, they will be redirected to login.

That's (similar to) how I handle the user profile page on my site, have a look there to see how it works. I have to admit that creating a 'user' page that is only accessible to registered users (precisely the thing you want to do) has not been on my mind when I designed the plugin. Rather I thought it would be done the way I describe it above. Tell me if that solves your problem.

I don't really understand your second problem: after a user logs in through the login page, they really should be logged in.

I hope this helps a bit.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] [Pagebuilder] User Login Conundrum In reply to
In Reply To:
1) Download the latest version of the plugin (contains some changes necessary for the steps below).
OK. We had 1.00.

In Reply To:
I don't really understand your second problem: after a user logs in through the login page, they really should be logged in.
We don't understand it either, but we found a temporary workaround. Add this line to the top of the login.html template ...
Code:
<%if from eq 'page' %> <%set url = "" %> <%endif%>
... has to be temporary because we don't know what side-effects it might cause.