Skip to content

updates V26+ #27

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

updates V26+ #27

wants to merge 1 commit into from

Conversation

smartbit
Copy link

@smartbit smartbit commented Feb 7, 2025

With these updates as suggested in Jan 5, 25 comment in Issue 24 and keycloak 26 upgrade docs

$ docker run -p 8000:8000 $(docker build -q .)

> [email protected] start
> node app.cjs

then the button appears http://localhost:8000. Pressing the button, in the console this line gives an error

    <button onclick="window.kc.login()">Login</button>

probably caused by change in v26 Methods for login are now async.

Suggestions for calling login() async are welcomed.

@smartbit smartbit force-pushed the ch2 branch 11 times, most recently from 669f364 to 685e30d Compare February 10, 2025 12:50
@smartbit smartbit changed the title updates for chapter2 updates V26+ Feb 13, 2025
@alexishp80
Copy link

alexishp80 commented Feb 21, 2025

Replacing the window.onload function with the following should fix the async login issue:

window.onload = function () {
            kc.init({ 'messageReceiveTimeout': 100000 }).then(function () {
                if (kc.authenticated) {
                    profile();
                } else {
                    document.getElementById('anonymous').style.display = 'block';
                    document.getElementById('anonymous').onclick = async () => {
                        await kc.login();
                    };
                }
            });
        }

Remove the onclick event from the button.

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

Successfully merging this pull request may close these issues.

2 participants