RocketChat / docs-old

Rocket.Chat's user documentation.
https://docs.rocket.chat
335 stars 769 forks source link

restore admin doc is incorrect #2082

Closed MasterDimmy closed 2 years ago

MasterDimmy commented 2 years ago

https://docs.rocket.chat/guides/administration/admin-panel/advanced-admin-settings/restoring-an-admin

db.getCollection('users').update({username:"administrator"}, { $set: {"services" : { "password" : {"bcrypt" : "$2a$10$n9CM8OgInDlwpvjLKLPML.eizXIzLlRtgCh3GRLafOdR9ldAUh/KG" } } } })

is wrong. Database has field "name" for username, not "username", so correct command to restore admin password to 12345 is:

db.getCollection('users').update({name:"administrator"}, { $set: {"services" : { "password" : {"bcrypt" : "$2a$10$n9CM8OgInDlwpvjLKLPML.eizXIzLlRtgCh3GRLafOdR9ldAUh/KG" } } } })

result:

rs0:PRIMARY> db.getCollection('users').update({username:"admin"}, { $set: {"services" : { "password" : {"bcrypt" : "$2a$10$n9CM8OgInDlwpvjLKLPML.eizXIzLlRtgCh3GRLafOdR9ldAUh/KG" } } } })
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })

rs0:PRIMARY> db.getCollection('users').update({name:"admin"}, { $set: {"services" : { "password" : {"bcrypt" : "$2a$10$n9CM8OgInDlwpvjLKLPML.eizXIzLlRtgCh3GRLafOdR9ldAUh/KG" } } } })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
dudanogueira commented 2 years ago

Hi! Thanks for reporting!

This command need to be adapted with the username to be have the password reseted. If you do not have a user with administrator as it's username, the command will change nothing.

It's easier to change using the username for the query, IMO.