Thursday, 15 January 2015

angularjs satellizer redirect back to previous page -


To handle my authentication with the local API, I am using a satellite operator in my angular code. Integrating any third party API authentication, everything is local if the user is with an invalid token, then I am working on the website, the system will redirect the user to the login page. If I need to get the requested link back after user login, how do I do this?

For example, if the user requests to use '/ client / description / 123', but the user will be redirected to the login page (/ account / login) after login is successful User / customer / description / 123 '

Satellizer is not helping you with this problem I also ran into this and made a service to handle it. So if a user is redirected to / login, I save the path in a service. After login, exit the service from the saved path and redirect it.

  1. When using 'UI-Router', find out every change by listening to '$ state changelog'. When the state changes and requires a login, save the current path by receiving it: '$ location.path ()'

  2. After login, $ Set path to location. Path ();

Hope this is helpful


No comments:

Post a Comment