Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PasswordResetLinkController ignores custom eloquent connection #55766

Copy link
Copy link
Closed
@leonardocustodio

Description

@leonardocustodio
Issue body actions

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

  1. Use a postgres database with 2 schemas, the first schema will be used for data, the second schema for auth related things.

  2. Configure a new connection with the second search_path an example:

        'auth' => [
            ...$pgsql,
            'search_path' => 'auth',
        ],
  1. Use this connection on the User model:
    protected $connection = 'auth';
  1. 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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.