implement name-main trick
This commit is contained in:
parent
095f4474b0
commit
65a910ff90
27
auth.py
27
auth.py
|
@ -25,18 +25,21 @@ def write_pwdb(pwdb, pwdb_path):
|
||||||
pwdb_file = open(pwdb_path, 'wt')
|
pwdb_file = open(pwdb_path, 'wt')
|
||||||
json.dump(pwdb, pwdb_file)
|
json.dump(pwdb, pwdb_file)
|
||||||
|
|
||||||
pwdb_path = 'pwdb.json'
|
|
||||||
pwdb = read_pwdb(pwdb_path)
|
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if __name__ == "__main__":
|
||||||
pwdb = add_user(sys.argv[1], pwdb)
|
pwdb_path = 'pwdb.json'
|
||||||
write_pwdb(pwdb, pwdb_path)
|
pwdb = read_pwdb(pwdb_path)
|
||||||
else:
|
|
||||||
username, password = get_credentials()
|
|
||||||
if username not in pwdb:
|
if len(sys.argv) > 1:
|
||||||
print('Wrong username!')
|
pwdb = add_user(sys.argv[1], pwdb)
|
||||||
|
write_pwdb(pwdb, pwdb_path)
|
||||||
else:
|
else:
|
||||||
if authenticate(username, password, pwdb):
|
username, password = get_credentials()
|
||||||
print('Successfully authenticated!')
|
if username not in pwdb:
|
||||||
|
print('Wrong username!')
|
||||||
else:
|
else:
|
||||||
print('Wrong password!')
|
if authenticate(username, password, pwdb):
|
||||||
|
print('Successfully authenticated!')
|
||||||
|
else:
|
||||||
|
print('Wrong password!')
|
||||||
|
|
Loading…
Reference in a new issue