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
username
optional (I guess this would be doable by modifying the users schema) but I am afraid that this could break theusers-permissions
plugin as it could rely on the fact thatusername
is always required and unique. - Another way could be using a middleware during registration that assigns user
email
tousername
property as well. In this caseusername
andemail
would have the same value, at least after the registration. Is there any pitfall into following this? - Another way is to add a
BEFORE INSERT TRIGGER
in 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
insert
with emptyusername
(or with a unique value) thenupdate
theusername
based 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.