Redirect unauthorized users to a custom page

1,063 views
Skip to first unread message

Sergio Manzi

unread,
Jul 10, 2013, 8:38:29 AM7/10/13
to joomla-de...@googlegroups.com
Sorry, I understand this is not matter for this group, but I have this problem, I tried to get help on forum.joomla.org, but nobody answered:

is there a way (I'm on Joomla! 3.1.1) to redirect unauthorized users to a custom page instead of to "/component/users/?view=login" ?

I'm asking this because in one of my sites I've set up a login page (accessible as /login) using mod_login (instead of the com_user login form) and for aesthetic reasons I would like unauthorized users trying to access restricted content be redirected to that same page instead of the different looking com_user login page.

It would be even better if the error message "You have to login first" would be displayed too, but this is not "a must".

Thanks in advance to whomever may give an advice.

Sergio

Franz

unread,
Jul 11, 2013, 7:56:31 AM7/11/13
to joomla-de...@googlegroups.com
I guess the easiest way to achieve what you need is to just redirect each time from "/component/users/?view=login" to "/login".
You can do this via .htaccess or with an advanced SEF extension.

For a little more control (i.e. checking if the user is in fact logged in or not, and so on) you may have to write a plugin to run onAfterInitalise.

Sergio Manzi

unread,
Jul 11, 2013, 9:23:45 AM7/11/13
to joomla-de...@googlegroups.com
Franz, that was the first thing I've think of, but unhappily I quickly discovered that it doesn't work at all because in case of unauthorized access the redirection to /component/users/?view=login is performed internally, by Joomla!, and it doesn't go through .htaccess. Even internal Joomla redirects do not work...  :-/

Thanks anyway!

Any other idea, anybody?

Sergio
--

Sergio Manzi

unread,
Jul 11, 2013, 11:20:00 AM7/11/13
to joomla-de...@googlegroups.com
Answering to myself and whomever may be interested:

It seems that the "/component/users/?view=login" redirection in case of
unauthorized access is hard coded into /includes/application.php

I'm afraid the only way to override it is to... "have kitten die"!

Thanks anyway!

Sergio
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-gene...@googlegroups.com.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> Visit this group at http://groups.google.com/group/joomla-dev-general.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Matt Thomas

unread,
Jul 11, 2013, 11:24:15 AM7/11/13
to Joomla! General Development
Well, that's not good (the hard coding, that is). I wonder if that can be improved, maybe in com_users? Might be a complex issue to solve.

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain



On Thu, Jul 11, 2013 at 11:20 AM, Sergio Manzi <s...@smz.it> wrote:
Answering to myself and whomever may be interested:

It seems that the "/component/users/?view=login" redirection in case of unauthorized access is hard coded into /includes/application.php

I'm afraid the only way to override it is to...  "have kitten die"!

Thanks anyway!

Sergio



On 2013-07-10 14:38, Sergio Manzi wrote:
Sorry, I understand this is not matter for this group, but I have this problem, I tried to get help on forum.joomla.org, but nobody answered:

is there a way (I'm on Joomla! 3.1.1) to redirect unauthorized users to a custom page instead of to "/component/users/?view=login" ?

I'm asking this because in one of my sites I've set up a login page (accessible as /login) using mod_login (instead of the com_user login form) and for aesthetic reasons I would like unauthorized users trying to access restricted content be redirected to that same page instead of the different looking com_user login page.

It would be even better if the error message "You have to login first" would be displayed too, but this is not "a must".

Thanks in advance to whomever may give an advice.

Sergio
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-dev-general@googlegroups.com.

Sergio Manzi

unread,
Jul 11, 2013, 11:32:14 AM7/11/13
to joomla-de...@googlegroups.com
Well, to the expense of the poor kitten I've solved changing just two files:

/administrator/components/com_users/config.xml

where I defined two new fields:
��� use custom redirection (Yes/No)
��� custom redirect URL (text)

and /includes/application.php

where, based on the two above parameters I redirect either to the standard /component/users/?view=login or the URL I defined.

There are *HUGE* security implications, I'm afraid, so this is something that will not be adopted by Joomla! core, I think...

Sergio



On 2013-07-11 17:24, Matt Thomas wrote:
Well, that's not good (the hard coding, that is). I wonder if that can be improved, maybe in com_users? Might be a complex issue to solve.

Best,

Matt Thomas
Founder�betweenbrain�
Phone: 203.632.9322
Twitter: @betweenbrain



On Thu, Jul 11, 2013 at 11:20 AM, Sergio Manzi <s...@smz.it> wrote:
Answering to myself and whomever may be interested:

It seems that the "/component/users/?view=login" redirection in case of unauthorized access is hard coded into /includes/application.php

I'm afraid the only way to override it is to... �"have kitten die"!

Thanks anyway!

Sergio


Reply all
Reply to author
Forward
0 new messages