Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No other event than "KeycloakEventType.Ready" dispatched #611

Open
somq opened this issue Jan 9, 2025 · 1 comment
Open

No other event than "KeycloakEventType.Ready" dispatched #611

somq opened this issue Jan 9, 2025 · 1 comment

Comments

@somq
Copy link

somq commented Jan 9, 2025

Not sure if I'm doing something wrong but I cannot get any other event than KeycloakEventType.Ready ({type: 'Ready', args: true}).

Following this example, I expect, for instance, to see AuthLogout and AuthSuccess events getting dispatched on logout/login to raise an explicit isConnecting flag.

Bug Report or Feature Request (mark with an x)

- [x ] bug report 

Versions.

  • Keycloak: v19.0.2
  • Angular 19

Repro steps.

The standalone example reproduces this behavior.

The log given by the failure.

Only KeycloakEventType.Ready ({type: 'Ready', args: true}) is dispatched.

Desired functionality.

It should report all states in KeycloakEventType enum.

@sergiunagy
Copy link

sergiunagy commented Feb 7, 2025

I'm using the something like the following snippet to understand the sequence:
effect(()=>{ const evt = this.#keycloakStatus(); console.log([AUTHSRV] ${new Date().getTime()} -- ${evt.type}-- ${JSON.stringify(this.#client)} ); ...

I'm then running a simple login on the keycloak client which successfully executes a sign in.
I saw the follwoing events so far. On sign in :
KeycloakEventType.Ready ,
KeycloakAngularInit

On refresh , I caught the following:
TokenExpired,
AuthRefreshSuccess

On Logout:
KeycloakEventType.Ready ,
KeycloakAngularInit

The issue seems to be that some events are lost during the context switch between initial page load (app server) , sign in page (Keycloak server) then back to page load (app server) which also re-runs initialization. Reload also happens on Logout so that signal state is also missed.

On sign in, keycloak will cache the state on the local browser and on the 2nd init it finds and loads it from there, basically authenticating the user.

I'm currently detecting the Ready state, then inspecting the authenticated status. I'm not sure this is the intended way of using it though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants