Skip to content
Discussion options

You must be logged in to vote

Hi @monsieurmerle, I need to correct my earlier reply. Your EDIT 2 approach is right, and my suggestion to use exec auth_guard(...) was wrong.

I mixed up what sqlpage.exec() and sqlpage.run_sql() do. sqlpage.exec() runs an external program; it does not include a SQL file. sqlpage.run_sql() can run another SQL file, but it gets its own variable context. That means a SET id_user inside it will not set $id_user in the parent page.

So yes, keep this at the top of each protected page:

set id_user = (...);

select 'redirect' as component,
       'login.sql?error' as link
where $id_user is null;

This is the same pattern used in SQLPage's authentication example. If you want to reduce the repetiti…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@monsieurmerle
Comment options

Comment options

You must be logged in to vote
1 reply
@monsieurmerle
Comment options

Answer selected by monsieurmerle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants