Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle errors from SSO server? #921

Closed
VladislavOshkanov opened this issue Dec 21, 2020 · 5 comments · Fixed by #929
Closed

How to handle errors from SSO server? #921

VladislavOshkanov opened this issue Dec 21, 2020 · 5 comments · Fixed by #929
Labels

Comments

@VladislavOshkanov
Copy link

Hi!
I need to handle errors from SSO server in my app, for example, if I got 404 on SSO url.
How can I handle this error in my app in order to prevent app from crash and show error message to user?
Thanks
image

@FabianGosebrink
Copy link
Collaborator

So my first try would be first: Wrapping the promise in the APP_INITILIZER and catch the errors, then redirect the user or show an alert or something, or in the main.ts catch the bootstrap fail of the app and do something there. Hope this helps.

@MGAMAL-SFI
Copy link

MGAMAL-SFI commented Jan 4, 2021

I have same issue my app crash when sso is down why?

@FabianGosebrink
Copy link
Collaborator

@mgamal-dev have you read my previous answer?

@MGAMAL-SFI
Copy link

Yeah, but I have some component will be public and not secured it is also crashed
When I add catch block it doesn't mean the app will show this page correctly

@FabianGosebrink
Copy link
Collaborator

FabianGosebrink commented Jan 4, 2021

You have to wrap the promise and catch errors with a reject/resolve. Did not try it out but I think this should work.

@VladislavOshkanov can you show me the configuration please?

You have to make sure the app can start by catching the Promise and resolving it. Currently you can ask for the config and check for null. I have a PR which introduces an event if the authwellknown could not have been loaded.

export function configureAuth(oidcConfigService: OidcConfigService) {
    return () => {
        return new Promise((resolve, reject) => {
            oidcConfigService
                .withConfig({
                    <your config>
                })
                .then(() => resolve(true))
                .catch(() => resolve(false));
        });
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants