ExLibrisGroup / primo-explore-devenv

A node.js , gulp based development enviornment for Primo's new UI customizations (css,images,html and javascript)
BSD 3-Clause "New" or "Revised" License
114 stars 84 forks source link

How to inject user information #125

Closed danizen closed 3 years ago

danizen commented 3 years ago

Hi,

Our library would like users to start in a user group without requesting privileges (via Terms of Use), and then once we are certain they've entered their address and phone number, we will change their user group to "PUBLIC" and the TOU will allow requests.

However, we would also like to let them know if they are logged in and in a particular user group, let's call it "PROVISIONAL", we want to give them a message under "Get It".

To do this, I was thinking I would implement a directive prmServiceHeaderAfter and check if the header was "Get It".

What is the best way to access the user information? AngularJS lets you inject dependencies, right? Is there a service or something that holds the user information?

NoamaExl commented 3 years ago

@danizen - I think the better approach will be to use the prm-opac-after hook - that way you know you are in the getit section for sure from there you should be able to access the jwtUtilService, in a way similar to this:

angular.element(document.querySelector('prm-opac-after')).scope().$ctrl.locationsService.jwtUtilService

The bold part is the part that can be accused through the parentCtrl object you should use in you code