Base solution for your next web application
Open Closed

CurrentUserDidNotLoginToTheApplication message not visible on angular app #12557


User avatar
0
Ricavir created

Hi,

When a user access token expires while using the angular app, a popup message "CurrentUserDidNotLoginToTheApplication" is shown to the user. The problem is that the user is redirected to the login page and he has no time to read the reason why he is redirected.

How can I fix that ?

Can I fix that by implementing ZeroTemplateHttpInterceptor ?

Thanks

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

3 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @Ricavir

    Sorry for the late reply. Could you please make the following change? This will use then instead of promise done to wait for the user to close the message. Could you please let us know if this change resolves the issue on your end?

    File: zero-template-http-configuration.service.ts

    handleUnAuthorizedRequest(messagePromise: any, targetUrl?: string) {
        if (
            this._route.url &&
            (this._route.url.startsWith('/account/login') || this._route.url.startsWith('/account/session-locked'))
        ) {
            return;
        }
    
        const self = this;
    
        if (messagePromise) {
            if (messagePromise.then) {
                messagePromise.then(() => {
                    this.handleTargetUrl(targetUrl || abp.appPath);
                });
            } else if (messagePromise.done) {
                messagePromise.done(() => {
                    this.handleTargetUrl(targetUrl || abp.appPath);
                });
            }
        } else {
            self.handleTargetUrl(targetUrl || abp.appPath);
        }
    }
    

    If the problem still persists, please feel free to contact us. Thank you.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    Ricavir created

    Hi @oguzhanagir,

    I've tried your suggestion but it didn't worked. Actually, I found the issue on class AbpHttpConfigurationService on method "handleAbpResponse"

    The promise from error message is not passed as argument to handleUnAuthorizedRequest method

    I've overrided it to fix this issue :

    handleAbpResponse(response: HttpResponse<any>, ajaxResponse: IAjaxResponse): HttpResponse<any> {
            var newResponse: HttpResponse<any>;
    
            if (ajaxResponse.success) {
    
                newResponse = response.clone({
                    body: ajaxResponse.result
                });
    
                if (ajaxResponse.targetUrl) {
                    this.handleTargetUrl(ajaxResponse.targetUrl);;
                }
            } else {
    
                newResponse = response.clone({
                    body: ajaxResponse.result
                });
    
                if (!ajaxResponse.error) {
                    ajaxResponse.error = this.defaultError;
                }
    
                this.logError(ajaxResponse.error);
                var **messagePromise **= this.showError(ajaxResponse.error);
    
                if (response.status === 401) {
                    this.handleUnAuthorizedRequest(**messagePromise**, ajaxResponse.targetUrl);
                }
            }
    
            return newResponse;
        }
    

    Whaat do you think ? Could you fix this issue on your side as well ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @Ricavir

    Thank you for your feedback and assistance. I will create an issue to resolve this issue. I will notify you when this package is released. Thank you.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)