twill icon indicating copy to clipboard operation
twill copied to clipboard

Make user class extensible

Open Tofandel opened this issue 1 year ago • 2 comments

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

Tofandel avatar Feb 21 '24 10:02 Tofandel

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

ifox avatar Feb 21 '24 10:02 ifox

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

Tofandel avatar Feb 21 '24 11:02 Tofandel