From 146d2c2c79061b64aab025a7bfbfca0b639ab573 Mon Sep 17 00:00:00 2001 From: Ashley Davis Date: Sat, 13 Apr 2024 18:15:08 +1000 Subject: [PATCH] Now removing the auth0| prefix from user id. --- backend/src/server.ts | 6 +++++- ...h0-6609076bbfe7556c8ab391dc => 6610f22eb8093839698e1ba4} | 0 ...h0-6610f22eb8093839698e1ba4 => 6610f22eb8093839698e1ba4} | 0 3 files changed, 5 insertions(+), 1 deletion(-) rename fixtures/50-assets/files/users/{auth0-6609076bbfe7556c8ab391dc => 6610f22eb8093839698e1ba4} (100%) rename fixtures/no-assets/files/users/{auth0-6610f22eb8093839698e1ba4 => 6610f22eb8093839698e1ba4} (100%) diff --git a/backend/src/server.ts b/backend/src/server.ts index b2c12456..96d69e7f 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -85,7 +85,11 @@ export async function createServer(now: () => Date, assetDatabase: IAssetDatabas return; } - const userId = (req.auth.payload.sub!).replace("|", "-"); + let userId = req.auth.payload.sub; + if (userId.startsWith("auth0|")) { + // Removes the auth0| prefix the user id. + userId = userId.substring(6); + } const user = await userDatabase.getOne(`users`, userId); if (!user) { res.sendStatus(401); diff --git a/fixtures/50-assets/files/users/auth0-6609076bbfe7556c8ab391dc b/fixtures/50-assets/files/users/6610f22eb8093839698e1ba4 similarity index 100% rename from fixtures/50-assets/files/users/auth0-6609076bbfe7556c8ab391dc rename to fixtures/50-assets/files/users/6610f22eb8093839698e1ba4 diff --git a/fixtures/no-assets/files/users/auth0-6610f22eb8093839698e1ba4 b/fixtures/no-assets/files/users/6610f22eb8093839698e1ba4 similarity index 100% rename from fixtures/no-assets/files/users/auth0-6610f22eb8093839698e1ba4 rename to fixtures/no-assets/files/users/6610f22eb8093839698e1ba4