playhouse icon indicating copy to clipboard operation
playhouse copied to clipboard

DO NOT MERGE: Show signout logic

Open taras opened this issue 2 years ago • 2 comments

Motivation

Using this branch to show how invoke code after sign out

Approach

in packages/app/src/App.tsx

const app = createApp({
  apis,
  components: {
    SignInPage: props => {
      const storage = useApi(storageApiRef);
      return (
        <SignInPage
          onSignInSuccess={async (identityApi: IdentityApi) => {
            props.onSignInSuccess({
              getProfileInfo() {
                return identityApi.getProfileInfo();
              },
              getBackstageIdentity() {
                return identityApi.getBackstageIdentity();
              },
              getCredentials() {
                return identityApi.getCredentials();
              },
              async signOut() {
                await identityApi.signOut();
                // happens after signout
                storage.remove('authenticated/user');
              },
            });
            // happens after successful authentication
            const identity = await identityApi.getBackstageIdentity();
            storage.set('authenticated/user', identity.userEntityRef);
          }}
          auto
          provider={{
            id: 'auth0-auth-provider',
            title: 'Auth0',
            message: 'Sign in using Auth0',
            apiRef: auth0AuthApiRef,
          }}
        />
      );
    },
  },
  bindRoutes({ bind }) {
    bind(catalogPlugin.externalRoutes, {
      createComponent: scaffolderPlugin.routes.root,
      viewTechDoc: techdocsPlugin.routes.docRoot,
    });
    bind(apiDocsPlugin.externalRoutes, {
      registerApi: scaffolderPlugin.routes.root,
    });
    bind(scaffolderPlugin.externalRoutes, {
      registerComponent: catalogImportPlugin.routes.importPage,
    });
    bind(orgPlugin.externalRoutes, {
      catalogIndex: catalogPlugin.routes.catalogIndex,
    });
  },
});

taras avatar Jul 24 '23 20:07 taras

⚠️ No Changeset found

Latest commit: 546d1677c3dfd53234c5a300487289d54871d20d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 24 '23 20:07 changeset-bot[bot]

📣 NOTIFICATION You are receiving this message because we did not publish any packages.

Generated by @thefrontside/actions Frontside

frontsidejack avatar Jul 24 '23 20:07 frontsidejack