By Daniel Chatelain on Wednesday, 06 January 2016
Posted in Technical Issues
Likes 0
Views 319
Votes 0
We just upgraded to 5.x so too late. We are still testing though the changes from 3.9 to 5.0.

One thing we have seen and we can't explain is that we have some blogs that can be read only when you are logged in so not public. We have a link on our homepage to go to several of these blogs. Before the upgrade, the user had a page saying he/she needed to be logged in to see the blog but now after the upgrade, the page displayed is the 400 message ( You are not authorized to view this blog entry.)

We must be missing something in the settings somewhere but we didn't see anything related to this.

Do you know where it can come from and how to resolve this?

We had to put the blogs public to avoid the problem so it is not ideal but better than a dead end like the 400 message.

As an example, we created this blog https://www.baypayforum.com/opinions/blogs/entry/test-of-access that can be only accessible when you are logged in. This works well. When not logged in, we get the 400 message.
Hi Daniel,

I am really sorry for the delay of this reply.

Can you try this instead and see how it goes?
if ($post->isAccessible()->allowed == false) { 
return $this->app->redirect(EBR::_('index.php?option=com_easyblog&view=login',false));
}
·
Thursday, 07 January 2016 11:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Daniel,

Based on the error message that you are getting, it's most likely that the post's category has a restrictive permission. Edit the category of your post and ensure that everyone can access blog posts from the particular category
·
Wednesday, 06 January 2016 11:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

You are right. There is a restriction on that blog but that's the intent.

What we want to do is to allow access to the blog only if you are a registered user.

Before the upgrade, when not logged in you were displayed a page that told you to login like you do with any Joomla article. Now after the upgrade, we only have a 400 error message.

What we would like to do is like before to ask the person to log in to see the blog post.

Does it make sense?
·
Wednesday, 06 January 2016 15:54
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Daniel,

Ah I see. I get what you mean now. This is actually a feature request that was requested by a lot of our customers as they do not want Google to be indexing these pages. Therefore it ended up as a 400 error instead.

If you want to customize this behavior, edit the file /components/com_easyblog/views/post/view.html.php and at line 58 locate the codes below,


if ($exception instanceof EasyBlogException) {
return JError::raiseError(400, $exception->getMessage());
}


Replace it with,


if (!$post->accessible()) {
return $this->app->redirect(EBR::_('index.php?option=com_easyblog&view=login',false));
}
if ($exception instanceof EasyBlogException) {
return JError::raiseError(400, $exception->getMessage());
}
·
Wednesday, 06 January 2016 22:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Mark for the reply,

We checked the file /components/com_easyblog/views/post/view.html.php but unfortunately, the folder post doesn't exist in the version we have (5.0.31).

We looked around and found /components/com_easyblog/views/entry/view.html.php instead. We tried to apply the patch in that file just to see. We got an 500 error. The method accessible is not defined.

Here is the error.log line:

[Wed Jan 06 10:51:48.268457 2016] [:error] [pid 23856] [client 10.0.1.12:52718] PHP Fatal error: Call to undefined method EasyBlogPost::accessible() in /var/www/baypay/components/com_easyblog/views/entry/view.html.php on line 58

Here is the modification to the php file (few lines before and after):

// Perform validation checks to see if post is valid
$exception = $post->checkView();

if (!$post->accessible()) { return $this->app->redirect(EBR::_('index.php?option=com_easyblog&view=login',false));
}

if ($exception instanceof EasyBlogException) {
return JError::raiseError(400, $exception->getMessage());
}

// Increment the hit counter for the blog post.
$post->hit();
·
Thursday, 07 January 2016 02:54
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Daniel,

Ah sorry! Too much coding for EasyDiscuss. It should be /entry/ . Try this code instead,

·
Thursday, 07 January 2016 03:16
·
0 Likes
·
0 Votes
·
0 Comments
·
No worry. I know the feeling.

We came back to the original version of view.html.php in the components/com_easyblog/views/entry folder.

We added the 3 lines you sent so now the file is:

// Perform validation checks to see if post is valid
$exception = $post->checkView();

if (!$post->isAccessible()->allowed) {
return $this->app->redirect(EBR::_('index.php?option=com_easyblogview=login',false));
}

if ($exception instanceof EasyBlogException) {
return JError::raiseError(400, $exception->getMessage());
}

// Increment the hit counter for the blog post.
$post->hit();

Result:

We are getting there. We get a 404 page displayed.
·
Thursday, 07 January 2016 05:42
·
0 Likes
·
0 Votes
·
0 Comments
·
Good job Ezrul. This one worked.

Thanks.
·
Friday, 08 January 2016 00:57
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for updating, glad that your issues are resolved now.

By the way, please remember to assign your domain to your license to obtain for support in the future. You can do so by accessing your license area at http://stackideas.com/dashboard
·
Friday, 08 January 2016 00:59
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post