diff options
author | Frederick Muriuki Muriithi | 2023-03-08 11:42:04 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-03-08 11:42:04 +0300 |
commit | a35d16f9a191afbb31e2c185e87e5eec5e23122f (patch) | |
tree | 2e56592510b7c4c8a53f513999d7104c1a1eb51a /main.py | |
parent | 5a8cc0d7fc241494580cd4a060690eaf09ff46d7 (diff) | |
download | genenetwork3-a35d16f9a191afbb31e2c185e87e5eec5e23122f.tar.gz |
auth: users: Use the same basic functions for password hashing
To avoid repeating the same thing in multiple places, leading to errors and
breakages, reuse the same basic functions for password hashing.
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -7,11 +7,11 @@ from datetime import datetime import click -from argon2 import PasswordHasher from yoyo import get_backend, read_migrations from gn3 import migrations from gn3.app import create_app +from gn3.auth.authentication.users import hash_password from gn3.auth import db @@ -36,13 +36,10 @@ def __init_dev_users__(): "name": "Test Development User", "password": "testpasswd"},) - def __hash_passwd__(passwd): - return PasswordHasher().hash(passwd) - with db.connection(app.config["AUTH_DB"]) as conn, db.cursor(conn) as cursor: cursor.executemany(dev_users_query, dev_users) cursor.executemany(dev_users_passwd, ( - {**usr, "hash": __hash_passwd__(usr["password"])} + {**usr, "hash": hash_password(usr["password"])} for usr in dev_users)) @app.cli.command() |