The application I am working on in needs minimal user information during registration to attract more people. Thus I would like to avoid asking for username from user during registration.
I am concerned about which would be the ideal way to achive this.
- I could make the
usernameoptional (I guess this would be doable by modifying the users schema) but I am afraid that this could break theusers-permissionsplugin as it could rely on the fact thatusernameis always required and unique. - Another way could be using a middleware during registration that assigns user
emailtousernameproperty as well. In this caseusernameandemailwould have the same value, at least after the registration. Is there any pitfall into following this? - Another way is to add a
BEFORE INSERT TRIGGERin MySQL. This trigger could add a username likeuser${id}to the new user. However this is a low level approach because it is applied on MySQL, and I would like to avoid it or implement it somehow differently. - Could be done also with MySQL transaction in the users-permissions controller (I mean first
insertwith emptyusername(or with a unique value) thenupdatetheusernamebased on what I read fromid).
Is there any advise on which is the best way to do this? Maybe some other approach I haven’t thought of could be really better and cleaner
If this is of importance, I am also planning to use social login through some of the authentication providers natively offered.