tsed icon indicating copy to clipboard operation
tsed copied to clipboard

[BUG] Page Keycloak - /tutorials/keycloak

Open dirkey opened this issue 2 years ago • 3 comments

If I try this example, but I get an error when starting the server:

TypeError: Cannot read properties of undefined (reading 'getMemoryStore')

I debug this a little bit and find out, the "store" configuration property is evaluated before the KeycloakService is injected. So, the this.keycloakService.getMemoryStore() fails.

dirkey avatar Sep 20 '22 19:09 dirkey

Hello @xCryzed Can you clarify this part of the doc please ;)

see you

Romakita avatar Sep 21 '22 05:09 Romakita

This solves the problem: Remove the session from the middleware and initialize the session in the $beforeRouteInit() method

 $beforeRoutesInit(): void {
    $log.info("beforeRoutesInit call")
    this.app.use(session({
      secret: "thisShouldBeLongAndSecret",
      resave: false,
      saveUninitialized: true,
      store: this.keycloakService.getMemoryStore()
    }));

    this.app.use(this.keycloakService.getKeycloakInstance().middleware());
  }

dirkey avatar Sep 21 '22 11:09 dirkey

Oops. I think the wrong example come from me when I refactored all code example. My Bad!!

Thanks for the PR ;)

Romakita avatar Sep 21 '22 14:09 Romakita

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 21 '22 02:12 stale[bot]

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

github-actions[bot] avatar Dec 31 '22 21:12 github-actions[bot]