Jiří Kalvoda
2 years ago
2 changed files with 27 additions and 1 deletions
@ -0,0 +1,26 @@ |
|||||
|
#!/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) |
Loading…
Reference in new issue