CERT-Polska/mwdb-core

how to recreate admin user?

Schi11ing opened this issue · 1 comments

Environment information

  • MWDB version (from /about): 2.8.0

  • Installation method:

    • From PyPi (pip install mwdb-core)
  • Plugins installed:

Behaviour the bug (what happened?)

Expected behaviour

Reproduction Steps

Screenshots

Additional context

Hello!
Can you please help me?
I have installed mwdb-core in my dev-env and forgot admin password, i cannot use reset link because of dev-env without smtp server installed, so how can i recreate admin user with new password whithout using email reset link?

psrok1 commented

Hi!

There is no handy utility for that, but you can help yourself using Flask Python shell:

First enter mwdb-core shell

# mwdb-core shell
Python 3.8.17 (default, Jun 15 2023, 03:35:59) 
[GCC 12.2.1 20220924] on linux
App: mwdb.core.app
Instance: /app/instance
>>> 

Then use it to set password in database:

>>> 
from mwdb.model import db, User
admin = db.session.query(User).filter(User.login == "admin").first()
admin.set_password("yournewpassword")
db.session.add(admin)
db.session.commit()