How to use a method with SiteMember permissions immediately after the user logs in?

Question:
How to use a method with SiteMember permissions immediately after the user logs in?

Product:
Wix Studio / VELO

What are you trying to achieve:
I am trying to use a webmethod with SiteMember permisson after the user log-in to the website.

What have you already tried:

I tried:

import { multiply } from 'backend/Users.web';
import { authentication } from "wix-members-frontend";

$w.onReady(async function () {

    await authentication.onLogin(async (member) => {
        const loggedInMember = await member.getMember();
        const memberId = loggedInMember._id;
        console.log(`Member ${memberId} logged in:`, loggedInMember);
        const isLoggedIn = authentication.loggedIn;
        if (isLoggedIn) {
            console.log('użytkownik zalogowany');
        } else {
            console.log('Użytkownik niezalogowany');
        }
        const x = await multiply(2, 4);
        console.log('wynik x=' + x);

    });

});

I also changed permisson in multiply method from Anyone to SiteMember.

The outcome is an error: No permission to access the web-method multiply in module backend/Users.web.js

Is it a bug?

When a user logs in, the authentication token that grants them SiteMember rights isn’t immediately “attached” to subsequent backend requests.
To ensure the user’s updated permissions are applied, you need to trigger a page reload or redirect immediately after login. This refresh ensures that the authentication token is attached to all subsequent requests, and your SiteMember–protected backend methods will be accessible.

Hi Dan,

yeah. That works, but it’s 'ugly" isnt it?
I am almost 100% sure that a week ago there was no issue with that.

But thanks!