Skip to content

Commit

Permalink
refactor(adapter-nextjs): remove redundant username fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Jan 2, 2025
1 parent 56dd741 commit 97957f7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,4 @@ describe('getAccessTokenUsernameAndClockDrift', () => {
}),
);
});

it('should return default username and clock drift when username is not present in the payload', () => {
mockDecodeJWT.mockReturnValueOnce({
payload: {},
});

expect(getAccessTokenUsernameAndClockDrift('accessToken')).toEqual(
expect.objectContaining({
username: 'username',
clockDrift: 0,
}),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getAccessTokenUsernameAndClockDrift = (
const decoded = decodeJWT(accessToken);
const issuedAt = (decoded.payload.iat ?? 0) * 1000;
const clockDrift = issuedAt > 0 ? issuedAt - Date.now() : 0;
const username = (decoded.payload.username as string) ?? 'username';
const username = decoded.payload.username as string;

return {
username,
Expand Down

0 comments on commit 97957f7

Please sign in to comment.