toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

Add/Delete users via command line

Open jettrich opened this issue 1 year ago • 2 comments

Dear Community,

I have a overleaf CE instance running, and I need to know how to add/delete users via command line, but unfortunately I haven't found any description yet. Please, could anyone point me in the right direction?

Kind Regards!

jettrich avatar Dec 13 '23 15:12 jettrich

Ok, in the meantime I found that I can get a list of users by a query to mongodb container:

$ docker exec mongo sh -c 'exec mongoexport -d sharelatex -c users -f email --type=csv'
2023-12-14T08:53:24.188+0000    connected to: mongodb://localhost/
2023-12-14T08:53:24.202+0000    exported 2 records
email
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
$

Then I can use bin/mongo to connect to the container, an use db.users.remove(...) to delete a user

db.users.remove({email:"[email protected]"})

QUESTION: Does the system take care of deleting also all files related to thast user?

Much the same way, I can connect to mongodb and use db.users.insert() to add a user

db.users.insert({email:"[email protected]"})

And I can set the password with a generated bcrypt hash as

db.users.update({email:"[email protected]"}, {$set:{hashedPassword:"$2y$12$_HERE_COMES_THE_SALT"}})

but I cannot login with the updated password. From a former post in overleaf repo I found that the user mentioned, that it worked using the correct hash. I've played around a bit, an I found that it worked using $2a at the beginning instead of $2y which is the default from htpasswd, since bcrypt version 2a is somehow old as far as I understood.

At the end I'm looking for a set of scripts, with which I'm able to create/delete users from my local Overleaf CE instance - I will keep on posting my findings here.

Cheers!

jettrich avatar Dec 14 '23 10:12 jettrich

Please, could someone show me how to create users by using the mongoimport command, as well a how to update passwords using mongoimport?

jettrich avatar Dec 14 '23 14:12 jettrich