JoseGoncalves / vue-keycloak

Keycloak plugin for Vue 3 with Composition API
Apache License 2.0
11 stars 4 forks source link

`keycloak.login()` won't work #6

Closed DEAN-Cherry closed 8 months ago

DEAN-Cherry commented 8 months ago

I am using keycloak.loing() method to login when the user is not authenticated and the init of vueKeycloak() works fine. But I just can't use keycloak.login() in any position (e.g. App.vue, RouteGuard...).


version: latest 2.5.0

index.ts:31 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'login') at keycloakLogin (index.ts:31:17) at call (call.mjs:4:17) at handleClick2 (Button.mjs:141:22) at callWithErrorHandling (runtime-core.esm-bundler.js:193:18) at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:201:17) at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:681:5)

DEAN-Cherry commented 8 months ago

Sry I forgot that the keycloak here is not a ref, which needs to be reassigned for each call.

JoseGoncalves commented 3 months ago

Hi @DEAN-Cherry. Since v3.0.0 keycloak is now a reactive reference to the keycloak-js adapter instance.