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

event:auth-loginRequired fired multiple times causing login dialog popup multiple times. #43

Closed
xmlking opened this issue Oct 12, 2013 · 8 comments

Comments

@xmlking
Copy link

xmlking commented Oct 12, 2013

I am using angular UI router that supports nested views. My nested views invoke multiple REST services at same time for for a given URL .when two REST calls receive 401 error, this module is broadcasting two loginRequired events.
This causes my login dialog pops up again after successful login. It would be nice if this module Wait for loginConfirmed() call before it broadcast next loginRequired event.

@eddiemonge
Copy link

maybe you should change your login dialog pop up to not fire if one is already open, say in maybe a service that handles that.

@xmlking
Copy link
Author

xmlking commented Oct 19, 2013

I am doing that as workaround, in my auth controller using a scope variable to suppress login popups until previous dialog is closed.
It would be nice if it is implemented in framwork level to delay subsequent 'event:auth-loginRequired' events untile e.g $stateChangeError or $stateChangeSuccess events received.

@eddiemonge
Copy link

Those should be done in your app. There is no way to account for all that (ngRoute vs ui-router vs custom) in this module.

@witoldsz
Copy link
Owner

@eddiemonge is right, just ignore the messages if you are still waiting for user to submit...

@tkrotoff
Copy link

Why not wait for loginConfirmed() or loginCancelled() before issuing new 'event:auth-loginRequired'?

@Mr-Anonymous
Copy link

how did you resolve this? I have the exact same scenario. If I have to add a check in service that opens the modal, how do I do that? Say my modal is called from a service like this everytime the 401 is thrown:

                                var modalInstance = $modal.open({
                                    templateUrl: 'views/LoginModalTemplate.html',
                                    controller: 'LoginModalCtrl'
                              });
                                modalInstance.result.then(function () {
                                        // If Confirmed
                                        authService.loginConfirmed();
                                }, function () {
                                        // If cancelled                                     
                                        //$state.go('index');
                                        authService.loginCancelled();
                                });

The above opens multiple login modals when http-auth-interceptor catches multiple 401's from the api for 1 page load. How do I stop the other modals from opening up when one is already existing? Do I need to add a switch to the $rootscope and check in service before the modal instance opens up? An example will greatly help please ..

@xmlking
Copy link
Author

xmlking commented Jul 25, 2015

@Mr-Anonymous
Copy link

Thanks heaps for that @xmlking That certainly gives me an idea now on how to approach this. Thanks again for helping. I was stuck on that for a long time wondering how to resolve it. Much appreciated. :)

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

No branches or pull requests

5 participants