Skip to content

Commit 93dac65

Browse files
committed
use jwt sub field when email not available
1 parent 7a6a7ab commit 93dac65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/plugins/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type AadToken = {
5959
amr: string[];
6060
appid: string;
6161
appidacr: string;
62-
email: string;
62+
email?: string;
6363
groups?: string[];
6464
idp: string;
6565
ipaddr: string;
@@ -176,7 +176,7 @@ const authPlugin: FastifyPluginAsync = async (fastify, _options) => {
176176
verifyOptions,
177177
) as AadToken;
178178
request.tokenPayload = verifiedTokenData;
179-
request.username = verifiedTokenData.email;
179+
request.username = verifiedTokenData.email || verifiedTokenData.sub;
180180
const userRoles = new Set([] as AppRoles[]);
181181
const expectedRoles = new Set(validRoles);
182182
if (verifiedTokenData.groups) {

0 commit comments

Comments
 (0)