Hey mate. I added this code to masterpage.js and it works.
import { authentication } from 'wix-members';
import wixLocation from 'wix-location';
$w.onReady(async () => {
authentication.onLogin(() => {
wixLocation.to(wixLocation.url)
});
});