I'm trying to implement public user automatic authentication (for permission management). When users access the website, I want them to be automatically connected under a single "public" user.
I tried this in app.component :
ngOnInit(): void {
//...
const currentUser = this.config.getOne("currentUser");
if(currentUser == null || currentUser.id == null){
const loginParams: LoginParams = {
username: 'public',
password: '**********'
}
this.authService.login(loginParams).subscribe(
() => {
window.location.reload();
}
);
}
}
window.location.reload()
is currently necessary to refresh the top right menu. If I don't reload the page, upon clicking on the user menu I get an error :
app.component.ts:38 ERROR TypeError: Cannot read properties of undefined (reading 'toggle')
at ToolbarContainerComponent.toggleCtxMenu (volosoft-ngx-lepton-x-layouts.mjs:373:22)
at ToolbarContainerComponent_Template_lpx_toolbar_profileClick_0_listener (volosoft-ngx-lepton-x-layouts.mjs:377:362)
at executeListenerWithErrorHandling (core.mjs:16195:16)
at Object.wrapListenerIn_markDirtyAndPreventDefault [as next] (core.mjs:16228:22)
at ConsumerObserver.next (Subscriber.js:91:33)
at SafeSubscriber._next (Subscriber.js:60:26)
at SafeSubscriber.next (Subscriber.js:31:18)
at Subject.js:34:30
at errorContext (errorContext.js:19:9)
at EventEmitter_.next (Subject.js:27:21)
How can I avoid reloading the page ?
I also tried moving the authentication code to an APP_INITIALIZER in app.module, but then, the authService is not yet initialized
Hi,
I have the exact same issue as 5179 (same abp version, angular, same configuration, same reproduce steps)
I see that you closed it without providing a solution. Is there a solution ?