Answer the question
In order to leave comments, you need to log in
How to connect authorization service in angular 1.5 component way?
Somewhat confused with the structure and feeling like I'm back to rootscope again anyway.
Where is authorization and work with an authorized user tied, so that it is a supercomponent level or something.
And it turns out that inside each of the components I need to call the function of checking the rights and obtaining the data of an authorized user. Or is it true?
I hope someone understands...
Answer the question
In order to leave comments, you need to log in
https://github.com/rwwagner90/angular-styleguide-es6
https://www.sitepoint.com/writing-angularjs-apps-u...
Good afternoon!
Checking rights can be on:
1) Accessing the page - refers to routing
2) Executing an http request - there is an http interceptor for this
3) Viewing specific DOM elements - a simple directive is enough
As well as a direct check of rights anywhere in the code, if this not enough.
There is a great library that gives you a turnkey solution for checking permissions.
As for the rootScope, you need to get the user profile from the server once, before loading any of the pages (which require special rights). You can create an appropriate service for it, or you can receive and store it in the service that is responsible for the session, and you will always have access to the profile.
First, resolve hasn't gone anywhere.
Secondly, you can use $transitions.onStart() which replaces $rootScope.$on('stateChangeStart')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question