fix stuff
This commit is contained in:
parent
095f4474b0
commit
8a07dbab02
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
pwdb.json
|
pwdb.json
|
||||||
|
__pycache__
|
13
auth.py
13
auth.py
|
@ -1,6 +1,8 @@
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
pwdb_path = 'pwdb.json'
|
||||||
|
|
||||||
def get_credentials():
|
def get_credentials():
|
||||||
username = input('Enter your username: ')
|
username = input('Enter your username: ')
|
||||||
password = input('Enter your password: ')
|
password = input('Enter your password: ')
|
||||||
|
@ -25,13 +27,13 @@ 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'
|
def main():
|
||||||
pwdb = read_pwdb(pwdb_path)
|
pwdb = read_pwdb(pwdb_path)
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
pwdb = add_user(sys.argv[1], pwdb)
|
pwdb = add_user(sys.argv[1], pwdb)
|
||||||
write_pwdb(pwdb, pwdb_path)
|
write_pwdb(pwdb, pwdb_path)
|
||||||
else:
|
else:
|
||||||
username, password = get_credentials()
|
username, password = get_credentials()
|
||||||
if username not in pwdb:
|
if username not in pwdb:
|
||||||
print('Wrong username!')
|
print('Wrong username!')
|
||||||
|
@ -40,3 +42,6 @@ else:
|
||||||
print('Successfully authenticated!')
|
print('Successfully authenticated!')
|
||||||
else:
|
else:
|
||||||
print('Wrong password!')
|
print('Wrong password!')
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
main()
|
Loading…
Reference in a new issue