Skip to main content

Posts · Flutter

Flutter

1 articles in total. Dart · Cross-platform Apps

October 31, 2026 Flutter

Who Does auth()->id() Actually Return? Lessons Learned from Sanctum Polymorphic Tokens and a Dual Membership System

A seemingly harmless auth()->id() call returns the owner of the token, not necessarily the member you expect. This post shows how polymorphic tokens work in Sanctum, why a two-member system silently mixes identities, and how binding a provider to each guard fixes it at the authentication layer.

WeChat

Scan to add me on WeChat

WeChat QR code