mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 03:08:42 -06:00
Fix login by serving users file via API
This commit is contained in:
@@ -8,7 +8,7 @@ export default function Login({ onLogin }) {
|
|||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/users.json")
|
fetch("/api/users")
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => setUsers(data.users || []))
|
.then((data) => setUsers(data.users || []))
|
||||||
.catch(() => setUsers([]));
|
.catch(() => setUsers([]));
|
||||||
@@ -30,7 +30,7 @@ export default function Login({ onLogin }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const hash = await sha512(password);
|
const hash = await sha512(password);
|
||||||
if (hash === user.password) {
|
if (hash.toLowerCase() === (user.password || "").toLowerCase()) {
|
||||||
setError("");
|
setError("");
|
||||||
onLogin(username);
|
onLogin(username);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -61,6 +61,20 @@ def serve_dist(path):
|
|||||||
def health():
|
def health():
|
||||||
return jsonify({"status": "ok"})
|
return jsonify({"status": "ok"})
|
||||||
|
|
||||||
|
# ---------------------------------------------
|
||||||
|
# User Authentication Endpoint
|
||||||
|
# ---------------------------------------------
|
||||||
|
@app.route("/api/users", methods=["GET"])
|
||||||
|
def get_users():
|
||||||
|
users_path = os.path.abspath(
|
||||||
|
os.path.join(os.path.dirname(__file__), "..", "..", "users.json")
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with open(users_path, "r", encoding="utf-8") as fh:
|
||||||
|
return jsonify(json.load(fh))
|
||||||
|
except Exception:
|
||||||
|
return jsonify({"users": []})
|
||||||
|
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
# Borealis Python API Endpoints
|
# Borealis Python API Endpoints
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
|
Reference in New Issue
Block a user