diff --git a/backend/add_user.py b/backend/add_user.py index 94676b2..66c6fea 100644 --- a/backend/add_user.py +++ b/backend/add_user.py @@ -1,15 +1,17 @@ import pymongo import getpass +import uuid myclient = pymongo.MongoClient("mongodb://admin:pass@localhost:27017/") username = input("Username: ") password = getpass.getpass("Password: ") +uuid = str(uuid.uuid4()) mydb = myclient["groclist_db"] mycol = mydb["groclist_users"] -mydict = {"username": username, "password": password} +mydict = {"username": username, "password": password, "groclist_uuid": uuid} if mycol.find_one({"username": username}): print("Username already exists\n") exit() diff --git a/backend/login.py b/backend/login.py new file mode 100644 index 0000000..df99046 --- /dev/null +++ b/backend/login.py @@ -0,0 +1,17 @@ +import pymongo +import getpass + +myclient = pymongo.MongoClient("mongodb://admin:pass@localhost:27017/") +username = input("Username: ") +password = getpass.getpass("Password: ") + +mydb = myclient["groclist_db"] +mycol = mydb["groclist_users"] + +#mydict = {"username": username, "password": enc_password} +if mycol.find_one({"username": username, "password": password}): + print("login success\n") + exit() +else: + print("Login Failed") +