Keyword

403 page when trying to view category as guest

  • George Varelas
  • George Varelas's Avatar Topic Author
  • Offline
  • New Member
More
12 years 4 months ago #66494 by George Varelas
403 page when trying to view category as guest was created by George Varelas
Hi all,
I checked simular topics but i cant see any answer to the problem
I have a menu item with link to a k2 kategory. Till now, the category was public and today i changed it to Registered because i dont want guests to read the articles of this category, only members.
The problem now is that if i press the menu to open the category i get a 403 error page and NOT a login form to continue reading.

Is there any fix? is it a problem with k2 or joomla?

Im using 1.5.23 and k2 2.4.1

thanks

Please Log in or Create an account to join the conversation.

  • George Varelas
  • George Varelas's Avatar Topic Author
  • Offline
  • New Member
More
12 years 4 months ago #66495 by George Varelas
Replied by George Varelas on topic Re: 403 page when trying to view category as guest
I tested it with a joomla article. I changed article permission to registered and when i use the menu at the frontpage, it returns a loginform.

In what way can i do the same with a k2 category with access level : Registered???

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago #66496 by enrique
Hi I have same problem, Have you olved it???

Thanks.

Please Log in or Create an account to join the conversation.

More
12 years 2 months ago #66497 by Arvind Ragunathan
Replied by Arvind Ragunathan on topic Re: 403 page when trying to view category as guest
You can try this:

I am using Joomla v2.5.6 and K2 v2.5.7

If your K2 category is set to registered and you have assigned a menu item to the registered category then you will receive "403 - You are not authorized to view this resource"

To resolve this issue we need to manually change the code on the backend.

1) Go To [SITE ROOT]\components\com_k2\views\itemlist\view.html.php

2) Find the code "JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));" which is contained in

$user = &JFactory::getUser();
if(K2_JVERSION=='16'){
if (!in_array($category->access, $user->authorisedLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$languageFilter = $mainframe->getLanguageFilter();
$languageTag = JFactory::getLanguage()->getTag();
if($languageFilter && $category->language!=$languageTag && $category->language!='*') {
return;
}
}

3) Replace the code "JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));" with:

if ($this->error->code = '403') {
$return = $_SERVER;
$return = base64_encode($return);
$uri = JRoute::_("index.php?option=com_users&view=login&return=$return");
header('Location:'.$uri); die();
}

4) Final code should look like:

$user = &JFactory::getUser();
if(K2_JVERSION=='16'){
if (!in_array($category->access, $user->authorisedLevels())) {
/*JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));*/
if ($this->error->code = '403') {
$return = $_SERVER;
$return = base64_encode($return);
$uri = JRoute::_("index.php?option=com_users&view=login&return=$return");
header('Location:'.$uri); die();
}

}
$languageFilter = $mainframe->getLanguageFilter();
$languageTag = JFactory::getLanguage()->getTag();
if($languageFilter && $category->language!=$languageTag && $category->language!='*') {
return;
}
}

5) This should resolve the issue.

6) You can do the same for [SITE ROOT]\components\com_k2\views\item\view.html.php

7) Find the code "JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));" which is contained in

if(K2_JVERSION=='16'){
if (!in_array($item->access, $user->authorisedLevels()) || !in_array($item->category->access, $user->authorisedLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}

8 Replace the code "JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));" with:

if ($this->error->code = '403') {
$return = $_SERVER;
$return = base64_encode($return);
$uri = JRoute::_("index.php?option=com_users&view=login&return=$return");
header('Location:'.$uri); die();
}

9) Final code should look like:

if(K2_JVERSION=='16'){
if (!in_array($item->access, $user->authorisedLevels()) || !in_array($item->category->access, $user->authorisedLevels())) {
/*JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));*/
if ($this->error->code = '403') {
$return = $_SERVER;
$return = base64_encode($return);
$uri = JRoute::_("index.php?option=com_users&view=login&return=$return");
header('Location:'.$uri); die();
}

}
}

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum