migrate to userExtra

This commit is contained in:
2026-06-12 00:39:44 +03:00
parent 6b633af95e
commit 1d6fc9fd6f
2 changed files with 7 additions and 6 deletions

View File

@@ -212,7 +212,7 @@ async def swipe(request):
"door": data["door"], "door": data["door"],
"approved": data["approved"], "approved": data["approved"],
"user": token.get("inventory", {}).get("owner", {}).get("username", ""), "user": token.get("inventory", {}).get("owner", {}).get("username", ""),
"uid_hash": data["uid_hash"], "userExtra": data["uid_hash"],
} }
await request.app.ctx.db.doorlog.insert_one(event_swipe) await request.app.ctx.db.doorlog.insert_one(event_swipe)

View File

@@ -72,14 +72,12 @@ async def slack_log_fwd(app):
print(e) print(e)
# -> approved, user, err # -> approved, user, err
def slack_authz(authGroup: str, slackId: str, slackName: str, channel_id: str) -> Tuple[bool, str, str]: def slack_authz(authGroup: str, slackId: str, channel_id: str) -> Tuple[bool, str, str]:
groups, user = kube.by_slackid(slackId) groups, user = kube.by_slackid(slackId)
if user is None: if user is None:
user = f"{slackId} (slack u/n: {slackName})" # slackName can be changed by user
if authGroup == "k-space:floor": if authGroup == "k-space:floor":
if channel_id == SLACK_CHANNEL_ID: if channel_id == SLACK_CHANNEL_ID:
print(f"WARN: slack #members open with unlinked ID: {user}") print(f"WARN: slack #members open with unlinked ID: {slackId}")
return True, user, f"This will stop working! Your Slack ID {slackId} is not linked with auth.k-space.ee, please notify info@k-space.ee." return True, user, f"This will stop working! Your Slack ID {slackId} is not linked with auth.k-space.ee, please notify info@k-space.ee."
return False, user, f"No user with slack_id {slackId}. Try in #members or doorboy.k-space.ee. Help at info@k-space.ee.", return False, user, f"No user with slack_id {slackId}. Try in #members or doorboy.k-space.ee. Help at info@k-space.ee.",
@@ -105,13 +103,15 @@ async def slack_open(request):
print(f"WARN: unknown slack door {door}") print(f"WARN: unknown slack door {door}")
return "Invalid door! (git.k-space.ee/k-space/doorboy-proxy)" return "Invalid door! (git.k-space.ee/k-space/doorboy-proxy)"
# user may be empty, if not linked to kube user
ok, user, err = slack_authz( ok, user, err = slack_authz(
authGroup, authGroup,
request.form.get("user_id"), request.form.get("user_id"),
request.form.get("user_name"),
request.form.get("channel_id"), request.form.get("channel_id"),
) )
userExtra = f"{request.form.get("user_id")} (slack u/n: {request.form.get("user_name")})" # slackName can be changed by user
doors = [door] doors = [door]
if door == "alldoors": if door == "alldoors":
# outside non-special doors # outside non-special doors
@@ -125,6 +125,7 @@ async def slack_open(request):
"door": d, "door": d,
"approved": ok, "approved": ok,
"user": user, "user": user,
"userExtra": userExtra,
} }
) )