I have this situation in the Laravel's login form where I check whether a user account is active or not. If the user is not active ('active' = false)
I log out the user (I don't let him log in) and show a message with a link saying Resend activation link, So this link takes to a controller that handles the resending by looking for the email of the form inside the request, but I am getting this error of email not found, since in the Request, the email is not being included!
Then the resulting query is:
"select * from
userswhere
emailis null"
because the email is not being kept inside the Request.
Any idea of what I am doing wrong?
If I dd($request)
just exactly in the login page, I do see the email
property. But then why isn't it being included in the request when clicking on the Resend link????
LoginController.php
protected function authenticated(Request $request, $user)
{
if(!$user->active){
Auth::logout();
dd($request->email); /*Here I do see the email*/
/*But here comes the problem, the email is not being kept in the request. Why???????????*/
return redirect('/login')->with('error','Please activate your account. <a href="'.route('auth.activate.resend').'"><strong>Resend</strong></a>');
}
}
dd($request) after logging in and active
= 0
+request: ParameterBag {#39 ▼
#parameters: array:3 [▼
"_token" => "o8t6GYwMmW6SfjfX732weghwejSBzOdWpcMf8HOL"
"email" => "me@somewhere.com"
"password" => "secreto"
]
}
At this moment, I show the Resend link and then
dd($request) after clicking on the resend
button
+request: ParameterBag {#46 ▼
#parameters: []
}
I see that the parameters section is now empty :(
I have also tried, inside the LoginController.php, $request->request->add(['email' => $user->email]);
but it doesn't work either.
Then how do I keep the email data in the Request so I can use it from a clicked link in another controller??? Is there any other workaround?