Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/garronej/oidc-spa
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Dec 8, 2023
2 parents de52932 + 6483d8f commit fe865e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ import { createOidc, decodeJwt } from "oidc-spa";
});

if (!oidc.isUserLoggedIn) {
// This return a promise that never resolve. Your user will be redirected to the identity server.
oidc.login({
// This return a promise that never resolve. Your user will be redirected to the identity server.
// doesCurrentHrefRequiresAuth determines the behavior when a user gives up on loggin in and navigate back.
// We don't want to send him back to a authenticated route.
// If you are calling login because the user clicked
Expand All @@ -105,11 +105,11 @@ import { createOidc, decodeJwt } from "oidc-spa";
idToken
} = oidc.getTokens();

const user = decodeJwt<{
const user = decodeJwt(idToken) as {
// Use https://jwt.io/ to tell what's in your idToken
sub: string;
preferred_username: string;
}>(idToken);
};

console.log(`Hello ${user.preferred_username}`);

Expand Down Expand Up @@ -198,11 +198,11 @@ function useUser() {

const user = useMemo(
() =>
decodeJwt<{
decodeJwt(idToken) as {
// Use https://jwt.io/ to tell what's in your idToken
sub: string;
preferred_username: string;
}>(idToken),
},
[idToken]
);

Expand Down

0 comments on commit fe865e2

Please sign in to comment.