Posts · Programming
Programming
1 articles in total. PHP · Frontend · Java · Flutter
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.