Skip to content

Commit c3fd1a2

Browse files
committed
fix(react): use decoded token directly instead of payload record
Fault on my part, was still accessing the payload object but jose returns it directly.
1 parent 5efd7fb commit c3fd1a2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/react/src/provider.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export function AuthProvider({
376376
/**
377377
* Custom hook to access authentication context.
378378
*
379-
* @returns {Object} An object containing:
379+
* @returns An object containing:
380380
* - isAuthenticated: boolean indicating if the user is authenticated
381381
* - values: object containing all values from the token
382382
* - loading: boolean indicating if the authentication state is being loaded
@@ -404,12 +404,8 @@ export function useAuth() {
404404

405405
export const decodeToken = (token: string): TokenPayload | undefined => {
406406
const decodedToken = decodeJwt(token);
407-
if (
408-
!decodedToken ||
409-
!decodedToken.payload ||
410-
typeof decodedToken.payload === "string"
411-
) {
407+
if (!decodedToken) {
412408
return undefined;
413409
}
414-
return decodedToken.payload as TokenPayload;
410+
return decodedToken as TokenPayload;
415411
};

0 commit comments

Comments
 (0)