add_user.py created. Adds user/pass to the database for using app.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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": password}
|
||||
if mycol.find_one({"username": username}):
|
||||
print("Username already exists\n")
|
||||
exit()
|
||||
else:
|
||||
x = mycol.insert_one(mydict)
|
||||
print("User created")
|
||||
|
||||
Reference in New Issue
Block a user