-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
We found that in the getFromToken function, the access token payload is decoded using atob. When the payload length is not a multiple of 4 (due to missing Base64 padding =), atob throws this error. This happens especially when the preferred_username claim contains an email (e.g., [email protected]).
Current Code:(in remember-me.service.ts)
const tokenBody = accessToken.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
const parsedToken = JSON.parse(atob(tokenBody));
Suggested Fix:
Add missing padding before calling atob:
while (tokenBody.length % 4 !== 0) {
tokenBody += '=';
}
Alternatively, using the jwt-decode library in Angular would be a more reliable approach.