Skip to content

Commit

Permalink
Fix cloud user signup bug - req.email not always being set
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorn committed May 17, 2021
1 parent 2bc0137 commit 3147d1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/back-end/src/services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ async function getUserFromAuth0JWT(user: {
return getUserByEmail(user["https://growthbook.io/email"]);
}

function getInitialEmailFromJWT(user: {
["https://growthbook.io/email"]?: string;
}) {
if (IS_CLOUD) {
return user["https://growthbook.io/email"] || "";
}
return "";
}

export function getJWTCheck() {
return IS_CLOUD ? getAuth0JWTCheck() : getLocalJWTCheck();
}
Expand All @@ -63,7 +72,7 @@ export async function processJWT(
res: Response,
next: NextFunction
) {
req.email = "";
req.email = getInitialEmailFromJWT(req.user);
req.permissions = {};

const user = await (IS_CLOUD
Expand Down

0 comments on commit 3147d1c

Please sign in to comment.