Overleaf: "user:create-admin" task: user.save is not a function

Created on 12 Mar 2020  路  3Comments  路  Source: overleaf/overleaf

Hi,
I'm trying to add an admin user and it might be, that the email is already existing as normal user.
docker exec sharelatex /bin/bash -c "cd /var/www/sharelatex; grunt -vv user:create-admin [email protected]"

I get the following error:

Running "user:create-admin" task
the options [appname] is not supported
using statsd
Set UV_THREADPOOL_SIZE=16
{"name":"default-sharelatex","hostname":"84c3a9392e9e","pid":15684,"level":30,"msg":"Using newsletter provider: none","time":"2020-03-12T22:16:05.151Z","v":0}
{"name":"default-sharelatex","hostname":"84c3a9392e9e","pid":15684,"level":30,"msg":"using smtp for email","time":"2020-03-12T22:16:05.791Z","v":0}
{"name":"default-sharelatex","hostname":"84c3a9392e9e","pid":15684,"level":30,"url":"mongodb://172.17.0.1/sharelatex","poolSize":10,"msg":"mongoose default connection open","time":"2020-03-12T22:16:05.879Z","v":0}
{"name":"default-sharelatex","hostname":"84c3a9392e9e","pid":15684,"level":30,"key":"mongo.UserGetter.getUserByAnyEmail","args":{},"elapsedTime":27,"msg":"[Metrics] timed async method call","time":"2020-03-12T22:16:05.893Z","v":0}
Fatal error: user.save is not a function

I think the error is in this line:
https://github.com/overleaf/overleaf/blob/7b2238ae584a38f29852d26f8c36db9f04468861/tasks/CreateAndDestoryUsers.coffee#L21

bug

Most helpful comment

You can set the isAdmin property in the DB:

$ docker exec -it mongo mongo
> use sharelatex
switched to db sharelatex
> db.users.update({email: '[email protected]'}, {$set: {isAdmin: true}})

You might need to restart sharelatex container after that.

All 3 comments

Yes, the problem is that such user already exists, the error message should be improved.

Is there a way to turn an existing user into an admin.

You can set the isAdmin property in the DB:

$ docker exec -it mongo mongo
> use sharelatex
switched to db sharelatex
> db.users.update({email: '[email protected]'}, {$set: {isAdmin: true}})

You might need to restart sharelatex container after that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianvb picture adrianvb  路  5Comments

ferdn4ndo picture ferdn4ndo  路  5Comments

Zeawiel picture Zeawiel  路  5Comments

erlef10 picture erlef10  路  9Comments

ASalvail picture ASalvail  路  3Comments