fix cli auth

This commit is contained in:
Jack Eilles 2024-03-26 15:01:06 +00:00
parent 39c084ea00
commit 8edf94b725
2 changed files with 27 additions and 39 deletions

View file

@ -65,9 +65,8 @@ def index():
ip = 0 ip = 0
# Now check the userid and idpass against the db # Now check the userid and idpass against the db
print(Config.users.find({"userid": request.form.get('userid')})) try:
print(Config.users.find({"userid": request.form.get('idpass')})) if Config.users.find_one({"userid": request.form.get("userid")})["userid"] == request.form["userid"] and bcrypt.check_password_hash(Config.users.find_one({"userid": request.form.get("userid")})["idpass"], request.form.get("idpass")):
if Config.users.find({"userid": request.form["userid"]})["userid"] == request.form["userid"] and Config.users.find({"userid": request.form["userid"]})["idpass"] == request.form["idpass"]:
# Init variables before they're passed # Init variables before they're passed
userid = request.form.get("userid") if request.form.get("userid") else None userid = request.form.get("userid") if request.form.get("userid") else None
@ -101,6 +100,11 @@ def index():
result, status = worker.shortenURL(url, ip, userid, id, retention) result, status = worker.shortenURL(url, ip, userid, id, retention)
return result, status return result, status
else:
return "Invalid userID or IDpass."
except Exception as e:
print(e)
return "Invalid userID or IDPass."
@app.route('/about') @app.route('/about')
def about(): def about():

View file

@ -1,16 +0,0 @@
# Might dockerise this stuff sooner or later, not now tho.
if [ $EUID -ne 0 ]; then
echo "This script must be run as root."
exit 1
fi
apt install mongodb-org python3-pip python3-venv
systemctl enable --now mongod
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
echo "Installation complete, launch xygt with ./run.py (in the venv)"