Closed neeravp closed 9 years ago
Redirects are not supported. You must pass your JavaScript data after the redirect has already taken place.
I am sorry for responding this late.
But I still can't figure out how to pass data after redirect. Any statement after return redirect()
will be inaccessible.
For ex: In the following snippet from controller code, the JavaScript data assignment would be inaccessible.
if ($this->auth->attempt(['email'=>$email, 'password' =>$password, 'status'=>'active'],$request->has('remember')))
{
$user = $this->auth->user();
return redirect()->intended($this->redirectPath());
JavaScript::put(['user' =>$user]); // this would be inaccessable
}
neeravp, it's because you are "returning" after the redirect. No code below a "return" will be processed - you have left that part of the ode and on to the intended redirect. You must pass the JavaScript in at a point like the intended redirect's Controller. If the redirect()->intended($this->redirectPath()) is something like AdminController@view, put it in that method.
Thanks jeffwalsh. I didn't occur to me to put it in the intended's controller. I will give it a try. Thanks again.
I am trying to put the authenticated user's role to access it from angular front end. So in my AuthController
What should I do to make it work with a redirect?