Answer the question
In order to leave comments, you need to log in
How to do authorization in AngularJs?
There is an application in angularjs. How to make authorization and authentication of users in the application itself.
At the moment, there is authentication, the server gives apikey, etc., and will not let you download anything without it. But menu items (for example) are still visible in the application, which should not be visible without authentication.
Maybe there are examples?
Answer the question
In order to leave comments, you need to log in
Everything is simple. You need to make 2 small services that will be responsible for all actions related to authentication. The first is the interceptor, it will insert everything you ask it into the headers of all requests, in your case it is apiKey. And the second service is checking this APIKey for validity through the server (if the key is not valid, the server should notify about it). The easiest way is to knock on the second function and reload the page depending on the response, and check the response in the menu controller and if you need to show or hide some items. A more correct way with watchers and digests. In the second case, there will be no unnecessary page reloads, and based on the response in the service, it will be possible to do a lot of things. If you need help - knock on Skype, I'll help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question