mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
set up auth
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import hashlib
|
||||
|
||||
|
||||
def encode_password(password: str) -> str:
|
||||
"""
|
||||
This function encodes the given password.
|
||||
|
||||
:param password: The password to encode.
|
||||
|
||||
:return: The encoded password.
|
||||
"""
|
||||
|
||||
return hashlib.sha256(password.encode("utf-8")).hexdigest()
|
||||
|
||||
def check_password(password: str, encoded: str) -> bool:
|
||||
"""
|
||||
This function checks if the given password matches the encoded password.
|
||||
|
||||
:param password: The password to check.
|
||||
:param encoded: The encoded password.
|
||||
|
||||
:return: Whether the password matches.
|
||||
"""
|
||||
|
||||
return encode_password(password) == encoded
|
||||
@@ -1,5 +1,8 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from app.utils.filesystem import get_home_res_path
|
||||
|
||||
|
||||
def getFlaskOpenApiPath():
|
||||
"""
|
||||
@@ -10,3 +13,19 @@ def getFlaskOpenApiPath():
|
||||
site_packages_path = [p for p in sys.path if "site-packages" in p][0]
|
||||
|
||||
return f"{site_packages_path}/flask_openapi3"
|
||||
|
||||
|
||||
def getClientFilesExtensions():
|
||||
"""
|
||||
Get all the file extensions for the client files
|
||||
"""
|
||||
|
||||
client_path = get_home_res_path("client")
|
||||
|
||||
extensions = set()
|
||||
for root, dirs, files in os.walk(client_path):
|
||||
for file in files:
|
||||
ext = file.split(".")[-1]
|
||||
extensions.add("." + ext)
|
||||
|
||||
return extensions
|
||||
|
||||
Reference in New Issue
Block a user