×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Public user not redirected to login

Public user not redirected to login 8 years 8 months ago #33619

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Hello Daniel,
A menu item which leads to front page submission of hotspot should redirect to login page if the user is not logged in.
But instead it goes to "403 - You are not authorised to view this resource."
It seem like there is a problem with redirection to login.

Thanks

Public user not redirected to login 8 years 8 months ago #33642

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Dima,
You would need to do this:
docs.joomla.org/Auto_redirect_guests_to_login

Regards,
Daniel
The following user(s) said Thank You: Dima um

Public user not redirected to login 8 years 8 months ago #33650

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Heh, very nice solution))
But I actually went a bit dipper, and coded a redirect into system template: any 403 will go to login page.
I figured there might be other pages with the same problem so this solves them all. ))

In case anyone interested, here is the code:
$user = JFactory::getUser();
if ($this->error->getCode() == '403' && $user->guest) {
	header('Location:index.php?option=com_comprofiler&view=login'); die();
}

This is going to the Community builder login page, but can be changed to whatever...

Public user not redirected to login 8 years 8 months ago #33651

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
that is awesome solution. I didn't think about that. But you should make sure that you only trigger that when the user is not logged in. If you are logged in and you get a 403, then you obvisouly don't have the correct permissions.

Public user not redirected to login 8 years 8 months ago #33657

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Thanks, updated the php above.
  • Page:
  • 1
Time to create page: 0.125 seconds