mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-29 09:52:36 +02:00

* Use a hashed password for ADMIN_PASSWORD A generate_password_hash manage.py command is provided Fixes #233 * Print a console warning for users using a clear text ADMIN_PASSWORD * Reword ADMIN_PASSWORD doc * Update changelog * Update CHANGELOG.rst - say it out loud - bump to 2.0 (that's the logic of semantic versioning while introducing breaking changes) * Bump to 2.0 (breaking change) * Update hashed password warning message * Mention the generate password hash in the Changelog
27 lines
678 B
Python
Executable file
27 lines
678 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
from flask_script import Manager, Command
|
|
from flask_migrate import Migrate, MigrateCommand
|
|
from werkzeug.security import generate_password_hash
|
|
|
|
from run import app
|
|
from models import db
|
|
from getpass import getpass
|
|
|
|
|
|
class GeneratePasswordHash(Command):
|
|
"Get password from user and hash it without printing it in clear text"
|
|
|
|
def run(self):
|
|
password = getpass(prompt='Password: ')
|
|
print(generate_password_hash(password))
|
|
|
|
migrate = Migrate(app, db)
|
|
|
|
manager = Manager(app)
|
|
manager.add_command('db', MigrateCommand)
|
|
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
manager.run()
|