I have the following problem. I'm developing a website using php and laravel 5.0.33. I have a development machine and a web server.
Now, I'm intercepting the register process by overriding the AuthenticatesAndRegistersUsers
postRegister
method, but with no luck because the interception is not performed on the server, on my local environment all works as expected.
I have also putted a die();
on the postRegister method of my AuthController, the one that overrides the defined on the mentioned trait and that line is never reached.
\Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers
:public function postRegister(Request $request) {
$validator = $this->registrar->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
$this->auth->login($this->registrar->create($request->all()));
return redirect($this->redirectPath());
}
\Project\Http\Controllers\Auth\AuthController
:use AuthenticatesAndRegistersUsers;
//Override of the register process
public function postRegister(\Illuminate\Http\Request $request) {
die ('aqui');
}
So, what is preventing the code from entering my overrode method? In both, my local dev machine and the server, the php versions are the same.
Edit: Bad news the same behavior happens if I try to log in a user on the website, the login is not working as the register. The request never gets to the controller. This has cost me a whole day....:(. On the login I also overrode a method.
So, the error was due to a misconfiguration on the virtual host done by the hosting providers in which all requests urls get a trailing slash, but if a POST request is done and the trailing slash is added then the consequent redirection transforms the POST request into a GET one. After two days of explaining this to the hosting providers, I got the access to modify the virtual host configuration and I added a rule to avoid redirecting POST requests.
This was the redirection before the fix:
# Enforce trailing slash policy
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /es/$1/ [L,R=301]
And the redirection after the fix:
# Enforce trailing slash policy
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /es/$1/ [L,R=301]
Thanks to all for your interest and responses.