Instead of passing the username as John Smith in username parameter of createUser function, you can use email id of the user or send any unique id. It will solve your issue. Regarding the actual username that you can save inside user profile or use Storage service to save user information.
Let me know if you required any help from our side.
P.S Please have a look at this custom code which will help you to obtain the same and managed using Storage service.