You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Vue 3 and I'm trying to integrate this library with my vue application. I'm using vue router and I need access to the keycloak attributes from the useKeycloak() hook. For example:
What I'd like to do is do some additional checks before sending to the actual route. What is the best way to access the keycloak object within the beforeEach? I've tried using the useKeycloak() but the data isn't available.
Any help would be appreciated.
The text was updated successfully, but these errors were encountered:
Hi @DavidzMwangi,
I solved it by adding before hook and creating custom wrapper for keycloak-js
// Restrict access to non-public routesrouter.beforeEach(asyncto=>{if(!to.meta.isPublic){awaitkeycloak.login()}})
The key was to properly check whether user is already authenticated before calling kc.login(). I just simply set flag isAuthenticated in onAuthRefreshSuccess and onAuthRefreshError and other available events. Then checks this flag before calling the actual kc.login()
Hello
I'm new to Vue 3 and I'm trying to integrate this library with my vue application. I'm using vue router and I need access to the keycloak attributes from the useKeycloak() hook. For example:
What I'd like to do is do some additional checks before sending to the actual route. What is the best way to access the keycloak object within the beforeEach? I've tried using the useKeycloak() but the data isn't available.
Any help would be appreciated.
The text was updated successfully, but these errors were encountered: