Username show
Build and Push Docker Image / build-and-push (push) Successful in 29s

This commit is contained in:
ciomek committed 2026-08-17 21:35:40 +02:00
1 parent 42e2fbcdb5
commit a603566235
4 files changed
+61 -13

No files matched your search

@@ -0,0 +1,32 @@
import json
from sqlmodel import Session, select
from loon.web.db import engine
from loon.web.users.models import User
async def show_username_handler(client, userdata, msg, data):
prefix = "loon/auth/show_username/"
if not msg.topic.startswith(prefix):
return
rest = msg.topic[len(prefix):]
uuid, _, subtopic = rest.partition("/")
if not uuid or subtopic:
return
with Session(engine) as session:
user = session.exec(select(User).where(User.uuid == uuid)).first()
if user is None:
client.publish(f"loon/auth/show_username/{uuid}/response",
json.dumps({"success": False, "error": "The user is not registered!"}))
return
internal_username = user.internal_username
client.publish(f"loon/auth/show_username/{uuid}/response",
json.dumps({"success": True, "error": None, "internalUsername": internal_username}))