fix(kaHasRoles): re-render on token refresh and auth events#671
Conversation
|
I have the same problem, please approve! |
|
@mauriciovigolo we're facing the same problem, and it would be interesting to fix this bug so we don't have to go around this problem |
|
@jhonataldsantos @hmichelotti-lab if you have production bug like me, before this PR can be merged and deployed, you can just create a import { Directive, effect, inject, Input, type OnChanges, type SimpleChanges,TemplateRef, ViewContainerRef } from '@angular/core';
import { KEYCLOAK_EVENT_SIGNAL, KeycloakEventType, type ReadyArgs, typeEventArgs } from 'keycloak-angular';
import Keycloak from 'keycloak-js';And import your own directive instead of the keycloak-angular one inside your components. |
Thank you @Maxouhell helped a lot! :) |
mauriciovigolo
left a comment
There was a problem hiding this comment.
Hey @Maxouhell,
thank you for solving this issue and opening the PR.
Great work! 💯
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The
*kaHasRolesdirective currently listens only to the Ready Keycloak event.As a result, role-based UI visibility is not updated when the access token is refreshed.
This patch enhances the directive to also respond to
AuthRefreshSuccess,AuthSuccess,TokenExpired, andAuthLogout events.This ensures that UI elements controlled by
*kaHasRolesare correctly re-evaluated after authentication or token lifecycle events.Issue Number: N/A
What is the new behavior?
*kaHasRolesdirective now listenAuthRefreshSuccess,AuthSuccess,TokenExpired, andAuthLogout events.Does this PR introduce a breaking change?
Other information
Tested in Angular 19.2 app keycloak-js 26 and Keycloak 26