This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

phplee
phplee

Hi,

Im building a subscription plugin which checks if the user is logged in before processing the order. Im using RainLabs User plugin. Is there any way to go back to my order once they login/register.

thanks

DMeganoski
DMeganoski

Well, not sure if there is an easier way in October, but in Laravel (which should still work) I used:

You should also be able to get the current / previous url in a string with


$previous = \Url::previous();
$current = \Url::current();

If the 'Url' facade has not been defined, you can access the class directly at \Illuminate\Routing\UrlGenerator

Now, since you are talking about logging the user in, there will be several redirects in the process so you will have to pass this url along as a variable at some point.

Figuring out how to pass the url in a request variable would probably be best, but if you can't do that, you can always store the url in the session.


\Session::put('prev_url', $previous);
phplee
phplee

thank you for taking the time to answer my question.

will try your solutions but seem the long way round. as documented using Auth:intended() should catch the intended url before it was redirected to the login page. However i have tried this and overtime i login after being denied it takes me to my members area and not the page i tried to load initially.

phplee
phplee

Got it working.

you need to use Redirect::guest($loginPage) and not Redirect::intended($loginPage) on the page you want to restrict. For example:

if (!Auth::check()) {
Flash::error(post('flash', trans('Please register or log in to continue.')));
return Redirect::guest($loginPage);
}

Last updated

jamiegrand
jamiegrand

Just what I was looking for Thanks ....

bahodursaidov

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.