Skip to content

Commit

Permalink
fix(oidc): logout trigger login (release) (#1394)
Browse files Browse the repository at this point in the history
* fix(oidc): logout trigger login

* fix (alpha)

* add use case to demo
  • Loading branch information
guillaume-chervet committed Jul 4, 2024
1 parent 388bd33 commit 6c80c5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions examples/react-oidc-demo/src/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { OidcSecure, type OidcUserInfo, OidcUserStatus, useOidcAccessToken, useOidcIdToken, useOidcUser } from '@axa-fr/react-oidc';
import {
OidcSecure,
type OidcUserInfo,
OidcUserStatus,
useOidc,
useOidcAccessToken,
useOidcIdToken,
useOidcUser
} from '@axa-fr/react-oidc';
import React from 'react';

interface OidcUserRoleInfo extends OidcUserInfo{
Expand Down Expand Up @@ -31,8 +39,10 @@ const DisplayUserInfo = () => {
};

export const Profile = () => {
const { logout, isAuthenticated } = useOidc();
return (
<div className="container mt-3">
<div className="contaicner mt-3">
{isAuthenticated && <p><button type="button" className="btn btn-primary" onClick={() => logout()}>logout</button></p>}
<DisplayAccessToken/>
<DisplayIdToken/>
<DisplayUserInfo/>
Expand Down
4 changes: 4 additions & 0 deletions packages/oidc-client/src/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio

loginPromise: Promise<void> = null;
async loginAsync(callbackPath:string = undefined, extras:StringMap = null, isSilentSignin = false, scope:string = undefined, silentLoginOnly = false) {
if (this.logoutPromise) {
await this.logoutPromise;
}

if (this.loginPromise !== null) {
return this.loginPromise;
}
Expand Down

0 comments on commit 6c80c5c

Please sign in to comment.