Hi,
This is because of the AuthFlowStrategy
.
It will listen all error about auth and refresh the app state, you can you overrride it.
For example:
import { AuthCodeFlowStrategy, clearOAuthStorage } from '@abp/ng.oauth';
import { OAuthErrorEvent } from 'angular-oauth2-oidc';
import { filter, switchMap, tap } from 'rxjs/operators';
import { EMPTY, from, of, pipe } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
export class MyAuthCodeFlowStrategy extends AuthCodeFlowStrategy {
override listenToOauthErrors() {
this.oAuthService.events
.pipe(
filter((event) => event instanceof OAuthErrorEvent),
tap((err: OAuthErrorEvent) => {
const shouldSkip = this.oAuthErrorFilterService.run(err);
if (!shouldSkip) {
const errRes = err.reason as HttpErrorResponse;
if(errRes.error?.error_description != "InactiveUser"){
clearOAuthStorage();
}
}
}),
switchMap((res) => {
if (res instanceof OAuthErrorEvent) {
const errRes = res.reason as HttpErrorResponse;
if(errRes.error?.error_description != "InactiveUser"){
return this.configState.refreshAppState();
}
}
return of(null);
} )
)
.subscribe();
}
}
export function overrideAuthFlowStrategy() {
AUTH_FLOW_STRATEGY.Code = (injector: Injector) => {
return new MyAuthCodeFlowStrategy(injector);
};
}
@NgModule({
......
providers: [
.....
{
provide: APP_INITIALIZER,
useFactory: () => overrideAuthFlowStrategy,
multi: true,
},
],
bootstrap: [AppComponent],
})
export class AppModule {}
Hi,
okay, i will chec check it
okay, could you share a test project that can reproduce the problem?(you can try use a new project to reproduce) I will check it. thanks.
shiwei.liang@volosoft.com
why there are duplicating /abp/application-configuration requests here? There are no our requests which might initiate them, so it looks like it is some inner ABP mechanism;
Some of them are Preflight requests, it's part of CQRS to pre-check if the server supports cross-domain requests.
https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
It is automatically sent by the browser, that's why you will see many same requests here.
you cannot see it from the ticket, but during /abp/application-configuration request our current page is redirected after unsuccessful link account login change. Even if we are currently on Home page - we are still redirected to Home page again. I have been setting breakpoints in our code, thinking it might be caused by our global error handler, but it responds to other error codes, not 400. So I thought it might have something to do with the way ABP handles this;
when I try to initiate "Link Accounts" dialog from another page (not Home page) - I still see error 401 after 'token_error' response from API requests of this page - just before the mentioned redirects to Home page. Error 401 makes no sense to me in the failed switch link account scenario, because the current user is never unauthorized. I would like you to explain why this could happen. Also, during the aforementioned redirection to the Home page, I briefly see "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io" markup - which might indicate that the current user is really unauthorized at some point (makes no sense to me).
Seems like angular will clear the login status after Link Accounts. you can describe what kind of behavior you want, and I will try to help you.
hi, you can check this https://github.com/abpframework/abp/issues/22472#issuecomment-2823633188
And update dbcontext to Implement interface IOpenIddictProDbContext
[ReplaceDbContext(typeof(IIdentityProDbContext))]
[ReplaceDbContext(typeof(ISaasDbContext))]
[ReplaceDbContext(typeof(IOpenIddictProDbContext))]
[ConnectionStringName("Default")]
public class MyProjectNameDbContext :
AbpDbContext<MyProjectNameDbContext>,
IIdentityProDbContext,
ISaasDbContext,
IOpenIddictProDbContext
Hi,
See https://github.com/abpframework/abp/pull/22315
you can override SaveChangesAsync
method of your DbContext to ignore OpenIddictApplication
type