Spaces:
Paused
Paused
Upload helpers/login.py with huggingface_hub
Browse files- helpers/login.py +15 -3
helpers/login.py
CHANGED
|
@@ -1,3 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from helpers import dotenv
|
| 2 |
+
import hashlib
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def get_credentials_hash():
|
| 6 |
+
user = dotenv.get_dotenv_value(dotenv.KEY_AUTH_LOGIN)
|
| 7 |
+
password = dotenv.get_dotenv_value(dotenv.KEY_AUTH_PASSWORD)
|
| 8 |
+
if not user:
|
| 9 |
+
return None
|
| 10 |
+
return hashlib.sha256(f"{user}:{password}".encode()).hexdigest()
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def is_login_required():
|
| 14 |
+
user = dotenv.get_dotenv_value(dotenv.KEY_AUTH_LOGIN)
|
| 15 |
+
return bool(user)
|