Description
Laravel Version
12.14.1
PHP Version
8.3.20
Database Driver & Version
Postgres
Description
Hello guys,
When using a custom $connection
on a User
class that extends the default Authenticatable
things works nicely for Login + Logout + VerifyEmail without any changes anywhere.
The thing is if we requests a password reset, it seems that the controller ignores the $connection
parameter even though all the others work fine.
My default configuration file for auth.php
is:
return [
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];
I understand that this probably can be solved by creating a database provider
and pass this new provider to passwords.users.provider
but since everything else works like a charm, maybe it would be interesting to fix this on the PasswordResetLink too
Steps To Reproduce
-
Use a postgres database with 2 schemas, the first schema will be used for data, the second schema for auth related things.
-
Configure a new connection with the second
search_path
an example:
'auth' => [
...$pgsql,
'search_path' => 'auth',
],
- Use this connection on the User model:
protected $connection = 'auth';
- Try to register, signin, signout, verify email, request a reset link. You will see everything will work with the exception of the reset link which seems to keep querying the default public schema. Resulting in the following error:
Illuminate\Database\QueryException
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "users" does not exist LINE 1: select * from "users" where "email" = $1 limit 1 ^ (Connection: pgsql, SQL: select * from "users" where "email" = leonardo@custodio.me limit 1)