Rocket Chat's password reset feature fails if the user has uppercase characters in their email address, e.g. John.Doe@example.com. An issue has been raised. Until it is resolved, a possible workaround is to convert all your users' email addresses to lowercase.
This solution converts all upper case email addresses to lower case. It assumes that Rocket Chat is run through docker compose
, but can easily be applied to any other setup with minor changes.
First, create a database dump in case something goes wrong
docker compose exec mongodb sh -c 'mongodump --archive' > db.dump
Then, load the interactive JavaScript shell to MongoDB inside the container
docker compose exec -it mongodb mongo
and select the rocketchat
database
use rocketchat
Check to see how many records are affected
db.users.find({ "emails.address": { $regex: /[A-Z]/ }}).count()
Update all instances to lowercase
db.users.find({ "emails.address": { $regex: /[A-Z]/ }}).forEach(function(doc) {
doc.emails.forEach(function(email) {
email.address = email.address.toLowerCase();
});
db.users.update({ "_id": doc._id }, doc);
});
Check again how many records are affected, the query should have a return value of 0
this time
db.users.find({ "emails.address": { $regex: /[A-Z]/ }}).count()
- Rocket Chat 6.7.0
- MongoDB 5.0.24