Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,21 +35,23 @@ from typing import Dict, Optional
|
|
| 35 |
import chainlit as cl
|
| 36 |
|
| 37 |
|
| 38 |
-
@cl.password_auth_callback
|
| 39 |
-
def auth_callback(username: str, password: str):
|
| 40 |
-
# Fetch the user matching username from your database
|
| 41 |
-
# and compare the hashed password with the value stored in the database
|
| 42 |
-
if (username, password) == ("admin", "admin"):
|
| 43 |
-
return cl.User(
|
| 44 |
-
identifier="admin", metadata={"role": "admin", "provider": "credentials"}
|
| 45 |
-
)
|
| 46 |
-
else:
|
| 47 |
-
return None
|
| 48 |
-
|
| 49 |
-
|
| 50 |
print(os.getenv("OPENID_PROVIDER_URL"))
|
| 51 |
print(os.getenv("OAUTH_CLIENT_ID"))
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
@cl.on_chat_start
|
| 54 |
async def on_chat_start():
|
| 55 |
app_user = cl.user_session.get("user")
|
|
|
|
| 35 |
import chainlit as cl
|
| 36 |
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
print(os.getenv("OPENID_PROVIDER_URL"))
|
| 39 |
print(os.getenv("OAUTH_CLIENT_ID"))
|
| 40 |
|
| 41 |
+
|
| 42 |
+
@cl.oauth_callback
|
| 43 |
+
def oauth_callback(
|
| 44 |
+
provider_id: str,
|
| 45 |
+
token: str,
|
| 46 |
+
raw_user_data: Dict[str, str],
|
| 47 |
+
default_user: cl.User,
|
| 48 |
+
) -> Optional[cl.User]:
|
| 49 |
+
if provider_id == "google":
|
| 50 |
+
if raw_user_data["hd"] == "example.org":
|
| 51 |
+
return default_user
|
| 52 |
+
return None
|
| 53 |
+
|
| 54 |
+
|
| 55 |
@cl.on_chat_start
|
| 56 |
async def on_chat_start():
|
| 57 |
app_user = cl.user_session.get("user")
|