-
- 1,118 Posts
Hi all, I am interested in learning more about the WebLogin Snippet - Does this relate to the Web User section of MODx?
I want to set up a password barrier page which i can use while i am building out a MODx website - I therefore want to add the password entry form onto the first page resolved when public view the site.
It would be fab if I could use WebLogin snippet and manage user access via the Web Users section - is this possible? How would one go about integrating this all together?
Many thanks
You are correct. Control web user access:
1. Create web user group; create document group; connect the two groups.
2. Create document, assign it to the document group. Now only logged-in users who are members of that web user group can see the document.
3. Assign web users to the web user group (automatically if you use the web signup snippet).
4. Add the WebLogin snippet to the page. You can configure the WebLogin snippet to specify which page the user goes to when he logs in, and what page to go to when he logs out.
You can also create an "unathorized" page with a login form on it, and assign that page as your "unauthorized" page in the site configuration.
-
- 24,544 Posts
If you want to protect the whole site, you just need to put the WebLogin snippet on a page and a simple snippet in your template that checks to see if the user is logged in and if not, redirects to the WebLogin page.
Of course you’ll need to create web users so they can log in.
-
- 24,544 Posts
Quote from: dubbs at Aug 12, 2009, 08:49 AM
Thanks guys works like a dream!
Only thing is i cant seem to logout?
This is the WebLogin call i have [[WebLogin? &loginhomeid=`3` &logouthomeid=`4`]]
I can login but cant logout?? Any ideas?
Are you, by chance in a Roach Motel? (Sorry -- couldn’t resist).
Try this:
[!WebLogin? &loginhomeid=`3` &logouthomeid=`4`!]
-
- 1,118 Posts
sweet ;] So best to use in the template rather than in the content via a snippet call then?
It can be anywhere you want it. The trick is that if it’s a dynamic snippet (you want it to behave differently on subsequent page requests) like any kind of form which needs to produce different output depending on the POST values, the snippet (or the document it’s on) has to be uncached. Once it’s cached, there’s no snippet to process anything on the next page request; the whole thing, including the original snippet output, is taken from cache.
When a document is taken from cache, it is given a pass through the parser to finalize a few things; if there were uncached snippet calls these are now processed, thus the POST or any other variables will be utilized.
-
- 139 Posts
Hi, I followed this and it’s working. But is it normal that the page is displayed when I I enter the URL manually? I’d like it to be only accessible to people logged in.
-
- 2,877 Posts
-
- 139 Posts
Thanks.
Apparently, I forgot to link something to something else (I believe, user group to document group?).
Now it’s working... only thing that is weird:
- when I go the the page using the friendly URL, I get a 404 error page. That’s okay with me.
- But, when I go to the page using the ID (or by right-clicking, then choosing ’Example’), I get some text saying: "In order to comment on blog entries, you must be a registered user of My MODx Site. If you haven’t already registered, you can request an account."
Where does this text come from? Does this have something to do with the example website (Modxhost) that is installed?