Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
fanno  
View profile  
 More options Jul 4 2012, 2:53 pm
From: fanno <fan...@gmail.com>
Date: Wed, 4 Jul 2012 11:53:18 -0700 (PDT)
Local: Wed, Jul 4 2012 2:53 pm
Subject: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

Hi all

We "Jfusion" have a option to redirect after login. how would i be able to
preform a costum redirect ?? The problem with the redirect is that since it
happens in onUserLogin and the remember me cookie is set AFTER this.

This means the remember me cookie is never set.

The problem is we cant use built in redirect because it only allow some
url's we need redirect option to be able to do to any site, even 3rd party
url's (as well as other sides) EG "SSL"

What i dont understand, or maybe miss stand is .. why do the remember me
need the results from onUserLogin/onLoginUser when the user has already
passed Authentication

should the remember me cookie not be set in between auth
and onUserLogin/onLoginUse ? I guess i can see a reason why not. In any
case i suspect this is not a "bug", but a "api" limitation pehaps we cant
add the redirect some other way a:
// Trigger  onUserLoginSucess Event.
$this->triggerEvent('onUserLoginSucess', array((array) $response));

perhaps add AFTER the remember me creation so that a redirect could be
executed there? I know tho that this would not solve out current "issue"

-Thanks
Morten

P.S.
I am open to any suggestion's you might have.
Dev on the JFusion project


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 5 2012, 2:36 am
From: Sam Moffatt <pasa...@gmail.com>
Date: Wed, 4 Jul 2012 23:36:12 -0700
Local: Thurs, Jul 5 2012 2:36 am
Subject: Re: [jbs] user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
An argument could be made that the remember me cookie code should
probably live in the Joomla! user plugin however in arguing where
things live login itself probably isn't best suited to the application
in general (there are apps that don't require login for example).
However I'm mildly confused because the login controller in com_user
already supports redirecting the user in 2.5, why not just change that
param?

Perhaps I'm not sure what the problem is, just set the return to be
where you want it to be. I just created a reasonably complicated URL
example to prove the point. It has SSL, is reasonably complicated (in
my mind anyway) and is an external site. Joomla! after login appears
quite happy to send the user there.

This example I wrote against 2.5, it won't work in 1.5 because the
extension is different. I'd argue the 2.5 behaviour is the best
because you can reset it from a plugin, you're not breaking your scope
(plugins randomly terminating application execution is something we
need to avoid) and it appears to be reasonably flexible unless I'm
missing something.

<?php

jimport('joomla.plugin.plugin');

class plgUserTest extends JPlugin
{
        public function onUserLogin()
        {

JFactory::getApplication()->setUserState('users.login.form.return',
'https://www.google.com/#hl=en&safe=off&sclient=psy-ab&q=joomla&oq=joo...
        }

}

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile  
 More options Jul 5 2012, 11:51 am
From: fanno <fan...@gmail.com>
Date: Thu, 5 Jul 2012 08:51:32 -0700 (PDT)
Local: Thurs, Jul 5 2012 11:51 am
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

You are right.

I will have to do next best thing.

                if (JFusionFunction::isJoomlaVersion()) {
//joomla 1.6+

JFactory::getApplication()->setUserState('users.login.form.return',
$return);
                } else {
                    $mainframe->redirect($return);
                }

out redirect need to happen to allow cross domain cookies to be set. tho it
may still need a tweek here and there.

-Thanks for your input Samuel

Den onsdag den 4. juli 2012 20.53.18 UTC+2 skrev fanno:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile  
 More options Jul 5 2012, 11:58 am
From: fanno <fan...@gmail.com>
Date: Thu, 5 Jul 2012 08:58:21 -0700 (PDT)
Local: Thurs, Jul 5 2012 11:58 am
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

I was to fast =( Logout has the same issue as with 1.5

Back to square one. Almost. we need logout aswell to preform the cross
domain removal of cookies.

Den torsdag den 5. juli 2012 17.51.32 UTC+2 skrev fanno:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 5 2012, 12:18 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Thu, 5 Jul 2012 09:18:22 -0700
Local: Thurs, Jul 5 2012 12:18 pm
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
Submit a patch to bring logout in line with login then and then
problem solved moving forwards. Alternatively you can detect a logout
with a system plugin and rewrite the request to go through your
extension and have any logic you need in there.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile  
 More options Jul 5 2012, 12:46 pm
From: fanno <fan...@gmail.com>
Date: Thu, 5 Jul 2012 09:46:18 -0700 (PDT)
Local: Thurs, Jul 5 2012 12:46 pm
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

Should, what git branch should i checkout to build the patch on ? i would
assume "master" ? 3.0 ? if i recall i read that master is now 3.0

-Thanks

Den onsdag den 4. juli 2012 20.53.18 UTC+2 skrev fanno:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile  
 More options Jul 5 2012, 2:17 pm
From: fanno <fan...@gmail.com>
Date: Thu, 5 Jul 2012 11:17:12 -0700 (PDT)
Local: Thurs, Jul 5 2012 2:17 pm
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

I have it setup in git, i just need to know what branch to base it on so
that i can create a pull request.

but i think it is a simple as one function changed:

public function logout()
{
JSession::checkToken('request') or jexit(JText::_('JInvalid_Token'));

$app = JFactory::getApplication();

        $app->setUserState('users.logout.form.return',
base64_decode(JRequest::getVar('return', '', 'method', 'base64')));

// Perform the log in.
$error = $app->logout();

// Check if the log out succeeded.
if (!($error instanceof Exception)) {
// Redirect the user.

$app->redirect(JRoute::_($app->getUserState('users.logout.form.return'),
false));

} else {

$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));

}
}

-Thanks

Den torsdag den 5. juli 2012 18.46.18 UTC+2 skrev fanno:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elin  
View profile   Translate to Translated (View Original)
 More options Jul 5 2012, 8:55 pm
From: Elin <elin.war...@gmail.com>
Date: Thu, 5 Jul 2012 17:55:52 -0700 (PDT)
Local: Thurs, Jul 5 2012 8:55 pm
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

For 3.0 use the master branch.

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile   Translate to Translated (View Original)
 More options Jul 5 2012, 9:38 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Thu, 5 Jul 2012 18:38:45 -0700
Local: Thurs, Jul 5 2012 9:38 pm
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
Yes, I guess this could technically be viewed as a new feature so it
should probably go into 3.0 lest we make 2.5 unstable again or
something.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Troy  
View profile   Translate to Translated (View Original)
 More options Jul 6 2012, 12:35 am
From: Troy <t...@hallhome.us>
Date: Thu, 05 Jul 2012 23:35:20 -0500
Local: Fri, Jul 6 2012 12:35 am
Subject: Re: [jbs] user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
*goes dizzy and faints*
Hey sam! I thought this was "English" list?

Bear

On 7/5/2012 1:36 AM, Sam Moffatt wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile   Translate to Translated (View Original)
 More options Jul 6 2012, 2:27 am
From: fanno <fan...@gmail.com>
Date: Thu, 5 Jul 2012 23:27:14 -0700 (PDT)
Local: Fri, Jul 6 2012 2:27 am
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

Yes let's not have that one happen again.

I have not made a pull request before I may be back here to ask if I do it correct.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile   Translate to Translated (View Original)
 More options Jul 6 2012, 12:07 pm
From: fanno <fan...@gmail.com>
Date: Fri, 6 Jul 2012 09:07:23 -0700 (PDT)
Local: Fri, Jul 6 2012 12:07 pm
Subject: Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

hmm i realise it is now a "development issue" but since i already have it
here i hope it is on to keep going here rather than moving to joomla dev...

$app->getUserState('users.logout.form.return') cant be used as after logout
has happen becuase $app->getUserState(...) pulls from session data and
since session is destroyed at this point it is "tolate" to retrieve it..

This means it cant be brought in to work the same way. what other methods
could be used ? that would work with both login/out ? or could something be
change so that the actual kill of the session only happens after it is
used? in this last location ?

i have not look deep in to it but joomla user plugin:

onUserLogout(....) {
....
$session = JFactory::getSession();
...
// Destroy the php session for this user
$session->destroy();
....

}

-Thanks

Den onsdag den 4. juli 2012 20.53.18 UTC+2 skrev fanno:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile   Translate to Translated (View Original)
 More options Jul 8 2012, 2:42 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Sun, 8 Jul 2012 11:42:12 -0700
Local: Sun, Jul 8 2012 2:42 pm
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
If we do some juggling we could use JRequest::setVar and a second
getVar to handle it.

e.g.
                $app = JFactory::getApplication();

                // Get the return url from the request and validate that it is internal.
                $return = JRequest::getVar('return', '', 'method', 'base64');
                $return = base64_decode($return);
                if (!JURI::isInternal($return)) {
                        $return = '';
                }
                JRequest::setVar('return', $return, 'method');

                // Perform the log in.
                $error = $app->logout();

                // Check if the log out succeeded.
                if (!($error instanceof Exception)) {

                        // Redirect the user.
                        $app->redirect(JRoute::_(JRequest::getVar('return', '', 'method'), false));
                } else {
                        $app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
                }

The return check is shifted before logout and resets the return param
in the request. This solves any injection of the return method that
the particular chunk of code is protected against with the isInternal
check. As an aside probably not a bad idea to put that back in the
above chunk of code though I'm not sure why it was removed to begin
with. Then the logout is called where in the session is destroyed and
your plugin run. In there you can call JRequest::setVar() to reset it
and if it completes without error the user will be sent on their merry
way.

Does this sound like a reasonable solution?

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile   Translate to Translated (View Original)
 More options Jul 9 2012, 5:42 am
From: fanno <fan...@gmail.com>
Date: Mon, 9 Jul 2012 02:42:22 -0700 (PDT)
Local: Mon, Jul 9 2012 5:42 am
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

would this not be better ? we as devs are used to the return value to be
encoded. Changing this could bad ?

i would say keep it encoded ?

I do not know if the  $return === false is really needed ? but it would
check against invalid content.

$app = JFactory::getApplication();

                // Get the return url from the request and validate that it
is internal.
                $return = JRequest::getVar('return', '', 'method',
'base64');
                $return = base64_decode($return);
                if (!JURI::isInternal($return)) {
                        $return = '';
                }
                JRequest::setVar('return', base64_encode($return),
'method');

                // Perform the log in.
                $error = $app->logout();

                // Check if the log out succeeded.
                if (!($error instanceof Exception)) {
$return = JRequest::getVar('return', '', 'method');
$return = base64_decode($return);
if ($return === false) {
$return = '';

}

                        // Redirect the user.
                        $app->redirect(JRoute::_($return, false));
                } else {
                        $app->redirect(JRoute::_('index.php?option=com_users&view=login',
false));
                }

-Thanks

Den søndag den 8. juli 2012 20.42.12 UTC+2 skrev Samuel Moffatt:

Den søndag den 8. juli 2012 20.42.12 UTC+2 skrev Samuel Moffatt:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 9 2012, 11:46 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Mon, 9 Jul 2012 20:46:10 -0700
Local: Mon, Jul 9 2012 11:46 pm
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
The URL being encoded is a minor obfuscation and avoidance of URL
double encoding problems in the request however if we're in the PHP
process neither are concerns any more (we're not going to have IIS
shut down the request for the double encoding since we're inside the
request). So I was trying to avoid the needless encoding/re-encoding
however I guess for backwards compatibility we could retain it in case
anyone is relying on that behaviour to set an internal redirect. That
said given 3.0 isn't guaranteed to be backwards compatible this is
perhaps one of the areas where it makes sense to break that and just
do the right thing from 3.x onwards.

Cheers,

Sam Moffatt
http://pasamio.id.au

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile   Translate to Translated (View Original)
 More options Jul 11 2012, 2:33 am
From: fanno <fan...@gmail.com>
Date: Tue, 10 Jul 2012 23:33:46 -0700 (PDT)
Local: Wed, Jul 11 2012 2:33 am
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

Could we not get problems with filters on request?

Or would all valid url characters stay intact?

Maybe a public function somewhere to set and get redirect url would be better since we don't have to worry about older. Versions??


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 12 2012, 1:16 am
From: Sam Moffatt <pasa...@gmail.com>
Date: Wed, 11 Jul 2012 22:16:34 -0700
Local: Thurs, Jul 12 2012 1:16 am
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

On Tue, Jul 10, 2012 at 11:33 PM, fanno <fan...@gmail.com> wrote:
> Could we not get problems with filters on request?

At this point we're already in the request and we've done any input
filtering we might have done. The only other filtering would be in the
component itself when we use JRequest to get it back out.

> Or would all valid url characters stay intact?

Valid URL characters would remain untouched. It'd just be a string in
PHP's memory that we're manipulating.

> Maybe a public function somewhere to set and get redirect url would be better since we don't have to worry about older. Versions??

We could do that though the only way I could see of reasonably doing
it is to create a static method in a class somewhere. It isn't a great
deal to re-encode and decode it to retain compatibility though I think
we should have a more generic approach somewhere however until that is
figured out and works in this case where we're killing sessions, using
this interface is probably a reasonable compromise.

In a sense a much better way would be able to make the authentication
system more configurable in general so that the level of integration
you wish to provide is easy to handle.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fanno  
View profile  
 More options Jul 12 2012, 8:50 am
From: fanno <fan...@gmail.com>
Date: Thu, 12 Jul 2012 05:50:10 -0700 (PDT)
Local: Thurs, Jul 12 2012 8:50 am
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)

What are you thinking OnUserRedirect ?

function OnUserRedirect($url) {

reutn $url;

}

or
function OnUserRedirect(&$url) {

}

A redirect hook called from system redirect? Allowing redirect to be change
if a plugin wants it to.

The hook should be called from the core redirect function in my eyes. This
gives a lot of flexibility i think.

I am not in core team or anything, but i don't feel like i cant make this
decision. But I have seen such hooks from other systems/software and it
seems to work quite nice. Not sure if this would affect performance. but
since it should only call if plugin register for the hook ... it should not
?

My personal opinion would be that is much more "clean" than reuse the
JRequest, there may be more data needed in the hook eg a status of some
kind but i think the URL would be enough

-Thanks

Den torsdag den 12. juli 2012 07.16.34 UTC+2 skrev Samuel Moffatt:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 12 2012, 10:53 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Thu, 12 Jul 2012 19:53:42 -0700
Local: Thurs, Jul 12 2012 10:53 pm
Subject: Re: [jbs] Re: user plugin redirect at login + remember me option "issue" (onUserLoginSucess maybe ?)
We can add a plugin trigger as well, however what is the expected
behaviour at that point when more than one result is returned? What if
two plugins return a redirect? The standard plugin logic doesn't make
sense here as the option is a single one off item, it can only be set
once. Something more inline with the authentication system's use of
plugins where it handles each plugin itself. I'm not sure that it
makes sense to put this in JApplication::redirect and be able to
rewrite every single redirect request without any context around it
happening - you'd essentially be getting a URL without much context
(or having to do nasty stuff with debug_backtrace to find it) which I
can potentially see as interesting but limited application.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »