mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
validate username and fixes
This commit is contained in:
parent
1284704293
commit
30b9c6237f
@ -5,6 +5,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -239,6 +240,9 @@ def create_user():
|
|||||||
|
|
||||||
request_data = request.get_json()
|
request_data = request.get_json()
|
||||||
|
|
||||||
|
if not re.match("^[A-Za-z0-9._]+$", request_data.get("username", "")):
|
||||||
|
make_response({"message": "Invalid username"}, 400)
|
||||||
|
|
||||||
password_hash = hash_password(request_data["password"], iterations=HASH_ITERATIONS)
|
password_hash = hash_password(request_data["password"], iterations=HASH_ITERATIONS)
|
||||||
|
|
||||||
User.insert(
|
User.insert(
|
||||||
@ -252,7 +256,7 @@ def create_user():
|
|||||||
|
|
||||||
@AuthBp.route("/users/<username>", methods=["DELETE"])
|
@AuthBp.route("/users/<username>", methods=["DELETE"])
|
||||||
def delete_user(username: str):
|
def delete_user(username: str):
|
||||||
User.delete_by_id(username).execute()
|
User.delete_by_id(username)
|
||||||
return jsonify({"success": True})
|
return jsonify({"success": True})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user