area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.72k stars 568 forks source link

Make user class extensible #2479

Closed Tofandel closed 6 months ago

Tofandel commented 6 months ago

Summary

We need to provide an option to be able to override the Twill\User class, it would make it possible to provide a custom getAuthIdentifier for sessions to work correctly without requiring a morph (otherwise if we have multiple User models and guards, the default laravel session which only uses user_id has an overlap of id which causes user to be able to see the sessions of other users) or override other behaviors like using UUID instead of ID

It would also allow us to add fillable fields to users

Describe the solution you'd like

A new config option: twill.user_model defaulting to Twill\User

ifox commented 6 months ago

Hi @Tofandel, that's already possible using twill.models.user: https://github.com/area17/twill/blob/3b5d66f870fbc46ad67a53e5b61f86711619a144/config/models.php#L12

Tofandel commented 6 months ago

I see thanks, there is still a few remnants of User::class though especially in the belongsTo of revisions and roles

I have noted 97+ usages of the User class in the code, so I'll send in a PR to fix this