This object is in archive! 

Is there any way by which the users can be forced to 'login' before they see the contents of the sit

Archived Srinivasan S. 12 years ago

Hi,

The requirement is that we want only valid users to see the contents of the site and not for anyone accidentally landing on the url. Hence, is it possible to force user login before they even see the already posted ideas, problems etc.,


On a separate note, is it possible to remove the self registration link, so to avoid unwanted registrations. The idea here is that registration of users will be done based on the role and should be visible only for users who have appropriate role.


Thanks

Srini

Best Answer
photo

Hiding content from guest visitors is possible by customizing UseResponse in the following way:


1) creating a module, with event handler for preDispatch, checking for logged user session (this will be executed prior to any page rendered). If user isn't logged in - redirecting him to separate login page (step 2);

2) adding separate page to display login form for this module;

3) overriding header template with your module, removing authentication links and popup;


Alternative way would be to utilize Login Plus module from UseResponse corporate edition, and integrate UseResponse with your site login process, replacing step 2 above with redirect to your site's login page.

Replies (17)

photo
1

Hiding content from guest visitors is possible by customizing UseResponse in the following way:


1) creating a module, with event handler for preDispatch, checking for logged user session (this will be executed prior to any page rendered). If user isn't logged in - redirecting him to separate login page (step 2);

2) adding separate page to display login form for this module;

3) overriding header template with your module, removing authentication links and popup;


Alternative way would be to utilize Login Plus module from UseResponse corporate edition, and integrate UseResponse with your site login process, replacing step 2 above with redirect to your site's login page.

photo
1

Currently it's not possible, but we'll take that into consideration for the upcoming releases to have the option for the closed community, so noone will see it until user is logged in.

Primarily UseResponse is for organizing open communities to gather feedback and provide support. To make ticket like system we are thinking of developing HelpDesk module, but it will be after 1.2 is released

photo
1

Has there been any progress on this? We have a separate support site so the primary purpose for us is to collect feedback/ideas from our customers and partners. We have many competitors looking for ideas and methods to compete with us, which is why this information should be locked to authenticated users. So in other words we want an 'open' community but only open to customers using our products and services.

photo
2

We don't have this in plans, but my suggestions will be writing custom module or switch on SSO login only, set See private objects to Registered users under Roles, and modify just a little bit so that by default responses are visible.

photo
1

Thanks Stas. Yes we will switch to SSO to inherit our Support site login. We have not tested this yet so I was not sure if there is still a way for guest users to see content or if they are always redirected to the login page of our support application.

photo
1

There is no such built in feature, but as I've mentioned above you can modify the code to make it

photo
1

Hi ,


Thanks for sharing the idea for custom module. I have written the script in the preDispatch on handler, If I use below condition $this->loggesUser->isGuest) { $this->rediect("login/redirect/reset"); . The page gets redirects continiously and getting redirecting loop message. Please guide us how to solve this issue. awaiting for your valuable reply.

photo
1

You could use jQuery only approach.

Just add following code within $(document).ready() block in global js or theme's scripts.js:

  1. if ($('ul.members-area').length == 0) {
  2. $('a.login-popup').trigger('click');
  3. }

photo
1

I created a custom module.

I added a handler with a preDispatch function. But it doesn't seem that the module is "launch". I would like this handler triggered when the page is loaded but I can't figure out how to do it.


Do I have to call the module somewhere ?

photo
1

Robin,

Make sure that your cutom module is installed and registered in system.

You also can install it manually by adding entry into <prefix>modules table. Don't forget to clean cache if $config['resources']['cachemanager']['globalCacheEnabled'] setting in configs/application.inc has "true" value.

Use Modules Development Manual for more information.

photo
1

The module is loaded correctly actually.

But it's the handler "preDispatch" who doesn't seem triggered. Do I need to include the handler somehow somewhere ?

photo
1

Robin wrote:

The module is loaded correctly actually.

But it's the handler "preDispatch" who doesn't seem triggered. Do I need to include the handler somehow somewhere ?

Maybe the reason is in incorrect class/method/file name? Make sure that all names are under UseResponse naming convetions.

photo
1

Ok, I fixed problem. It was a mix with a cache problem and a bad written function.

Thanks you.

photo
1

Robin,

Glad that you've found how to fix it.

photo
1

How can I call external function in my handler ?

I would like to call function from a controller but I can't figure out how.


If I want to implements some logic, should I write it in a controller, a services ? or a resource ?


Also, if I want to redirect to a login page like you said in the official answer. Which function should I use ?

I try $this->rediect("login/redirect/reset");


But I have an error, "Using $this when not in object context". I don't have access to the "$this" keyword in handler.


Thanks

photo
1

$this->redirect(....) can be used in controllers only.

If you want to use if outside controller call it as:

  1. Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')
  2. ->setGotoRoute(array(), 'default');

or

  1. Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')
  2. ->gotoUrlAndExit($yourUrl);

If you want to interfere in system behavior all logic can be described in handlers, also you can split your code logic on methods by creating your own "Service" class.

photo
1

Thank you very much it works.

Replies have been locked on this page!