By Dean on Tuesday, 14 June 2016
Posted in Technical Issues
Replies 4
Likes 0
Views 723
Votes 0
I am designing a site intended to be private.

I want EasyDiscuss to refuse to display any page of the component if a user is not logged in. I think this is as simple as putting one-line of code that tests and redirects somewhere but I'm not hip to all of the variables. I have gone through all of the back-end settings and do not see anything like this.

Could you please let me know how to accomplish this? In the backend I currently have EasyDiscuss set as the Login Provider.

Thank you in advance, you all are great!
To add a little bit of clarity about this...


  • Joomla has a menu item linking to EasyDiscuss.
  • That menu item has been configured to allow only registered users.
  • When attempting to open that page I am correctly redirected to a login page.


Here is my problem:

If I manually enter a non-menu-item link to the component like so:

http://localhost/joomla/index.php?option=com_easydiscuss&view=index

I am allowed to view that page even if I am not logged in. I want the component itself to have a check to prevent hackers from manually entering a component's URI and circumventing the intended design of my site.
·
Tuesday, 14 June 2016 10:35
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello there,

Sorry for the delay of this reply.

To solve this problems, there is two method. Below are those method you should try to solve your problems.

Method 1
You have to do some restriction at Backend>Component>EasyDiscuss>Categories>Permission as shown int this screenshot http://screencast.com/t/hZEuzHOSxVK, they will be redirect to these page as shown in the link http://screencast.com/t/YBY1Gtt7Q. There will no category posted shown.

Method 2
You can add code below at view.html.php as shown http://screencast.com/t/qQ8u4yvR3TN , at this path ...\wJoomlaED\components\com_easydiscuss\views\index\view.html.php


// get your current logged in user id
$userId = JFactory::getUser()->id;

// if that is guest, we direct them to login page
if (!$userId) {
return $this->app->redirect('http://localhost/joomla/index.php?option=com_easydiscuss&view=index');
}

This method will redirect them to the user's login page as shown http://screencast.com/t/yhgkQXfAQF


Hope this help
·
Tuesday, 14 June 2016 13:05
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Abdul,

I've done both now. I optimized your code snippet a bit and came up with this:

if (! JFactory::getUser()->id) {
return $this->app->redirect(JURI::base());
}


I experimented with putting this in a template override but couldn't figure out a reliable way. I will make sure to document this so it can be re-applied after an upgrade.

Thank you!
·
Wednesday, 15 June 2016 02:34
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello there,

Sorry for the delay of this reply.

It is possible to template override ..\components\com_easydiscuss\views\index\view.html.php this kind of file, it is only possible to override the theme file only. For example, JoomlaFolder\components\com_easydiscuss\themes\wireframe\frontpage\default.php

You should backup this file as when new update is released you can override it again next time.

As a gentle reminder, kindly start a new thread if you have any other issue in the future so it will be easier for us to manage your inquiry. I will lock and mark this thread as resolved.

Hope this help
·
Wednesday, 15 June 2016 11:42
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post