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

@@ -72,14 +72,12 @@ async def slack_log_fwd(app):
print(e)
# -> 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)
if user is None:
user = f"{slackId} (slack u/n: {slackName})" # slackName can be changed by user
if authGroup == "k-space:floor":
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 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}")
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(
authGroup,
request.form.get("user_id"),
request.form.get("user_name"),
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]
if door == "alldoors":
# outside non-special doors
@@ -125,6 +125,7 @@ async def slack_open(request):
"door": d,
"approved": ok,
"user": user,
"userExtra": userExtra,
}
)