Skip to content

[6.x] Fix OAuth connections for Eloquent users - #15266

Open
FlxRobole wants to merge 1 commit into
statamic:6.xfrom
FlxRobole:6.x
Open

[6.x] Fix OAuth connections for Eloquent users#15266
FlxRobole wants to merge 1 commit into
statamic:6.xfrom
FlxRobole:6.x

Conversation

@FlxRobole

Copy link
Copy Markdown
Contributor

Problem

The OAuth provider disconnect/connect method currently throws a BadMethodCallException: Call to undefined method App\Models\User::id() error for all eloquent-managed users:

statamic_oauth_error

Both, the cause and fix for this error is quite similar to #10848: The connect and disconnect methods pass the raw App\Models\User model to the vendor code that calls id(), which is only available on Statamic user wrappers.

(see discussion on discourse)

Reproduction

  1. Configure Statamic to use the eloquent user repository and an auth provider as per statamic docs (tested with azure & github).
  2. Use a standard Eloquent user model (without an id() method, obviously).
  3. Sign in using email/password.
  4. Open the "Profile > Sign-In providers" page and connect (or disconnect) a provider.

The callback throws the 500 exception.

Fix

  • Normalize authenticated models using User::fromUser() before connecting or disconnecting providers.
  • Adds some tests that cover connecting, reconnecting, and disconnecting with an Eloquent user (generated by Codex 5.6 Sol Ultra).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant