This forum has moved, please join us on github discussions. We will keep these old posts available for reference. Thank you!

Possible to change username?

It happens with some frequency that users enter a misspelled email address for the value used to create their account, and we need to be able to address this for them.

I can, of course, write a db query to change the username field when triggered via an API request, but I imagine there may downstream affects in terms of the aposDocVersions table, etc.

Could you confirm if this is an update I can safely make without breaking table relationships / anything else?

1 Like

You can update that field, either via “Manage Users” or (since it seems clear you are asking how to do it programmatically) via calling apos.users.find to find them and apos.users.update to update them. Just use the “front door” for this and you should be fine. You are correct to be nervous about doing it via Mongo — the username is one of the fields that is mirrored in the “safe” that holds password hashes in a separate collection to rule out any accidental exposure. Use the official Apostrophe APIs and you should be OK.

1 Like

Perfect, the apos.users.update front door was exactly what I needed. Thanks Tom!