Hi,

There are 3 login scenarios which I would like to implement and would appreciate some help with 2 and 3:

Scenario 1: everyone can read content (including boxes) but needs to login for posting or administering. In that case the login box appears on every page until the user is logged in.
I menaged to implement that scenario.

Scenario 2: everyone can read the overviews and see the boxes on the front page but has to login for access beyond the front page or for posting or administration. In that case the login box should appear only on the front page.

Scenario 3: no one has access to nowhere. The front page should show the login box only.

Thanks

Comments

lusko’s picture

I think cvs version has it by default.
However, one possible solution, if you want to add more into that (like intro page with logo etc) and/or take header and footer out, is using the page hook and using "access content" permission in a new module. Then define the new module as index and check the permission for authenticated users in admin.

al’s picture

You'd do well to read this part of the docs, which will let you achieve #2.

#3 can be achieved by simply denying the anonymous role any user permissions at all (no "access content" permission).

Note that you might want to make anonymous users' front page the login page (rather than just having the block). This can be done by hacking index.php - check out the thread here.

Roy’s picture

by just making "user" the default front page. It seems to work well except when trying to approach a node (by direct URL for example). In that case Drupal sends a blank page with the message "access denied" and not the login page.
In my post I was actually asking for advise about how to fix this though I encountered the problem from a different direction: using "node" as the default front page without granting any permissions to anonymous users.
Anyway, this problem should be fixed.

As for scenario #2, the real problem is not limiting the appearance of the boxes (the samples in the relevant docs page needs to be updated) but limiting anonymous access to the front page only. Any advise on how this can be done?

Thanks

al’s picture

I'd have thought most people if they'd followed a link to your.site.com/node/123 would be confused if it dumped you at the home page. If access is denied, there's a nice login block for dealing with that sitting next to that message.

I'd say the current behaviour is entirely sensible. Perhaps it could be improved by providing a small link to your.site.com/user underneath the "Access denied" text?

As for your second point - anything which isn't the front page goes through module.php, so you could put a check at the top of that fileto redirect to the front page unless you're logged in.

if (!$uid) {
drupal_goto("/");
}

(Or something.)

This has the problem that links to all the content, etc. are still there, just fail to work. This will confuse your users - it might be more appropriate to display a message saying "access to content only available if you log in" or whatever.

There are no hooks to stop you from searching, etc. You'd need to restructure the whole of Drupal to do it in a non-hacky way. This does strike me as an extremely strange request, BTW. Only local images are allowed.

Roy’s picture

If access is denied, there's a nice login block for dealing with that sitting next to that message.
That works with any module except node...

it might be more appropriate to display a message saying "access to content only available if you log in" or whatever.
If such message could be presented at the bottom of the overviews instead of the links that could be fine but it seems that the if/else thing should be inserted in the template.. but the template does not recognize $uid ...

This does strike me as an extremely strange request
I need to use that scenario in order to tempt readers to register and agree to receive advertisment email. I don