You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
695 B
26 lines
695 B
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
from hra.util import hash_passwd
|
|
from sqlalchemy import exc, update
|
|
import sys
|
|
|
|
import hra.db as db
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("username", help="Username")
|
|
parser.add_argument("passwd", help="Password")
|
|
parser.add_argument("--org", help="Přidělí org prává", action='store_true')
|
|
|
|
args = parser.parse_args()
|
|
|
|
u = db.User(org=args.org, username=args.username, passwd=hash_passwd(args.passwd))
|
|
u.gen_token()
|
|
try:
|
|
db.get_session().add(u)
|
|
db.get_session().commit()
|
|
except exc.IntegrityError:
|
|
print("Uživatelské jméno již existuje")
|
|
sys.exit(1)
|
|
print("Přidán nový uživatel.")
|
|
print(u.token)
|
|
|