I am working on a node application that uses Express and Passport for authentication and authorization, and it all works correctly. However, I am at a dead end on how to get the current user (set as req.user by Passport) in my Angular controllers.
I want to be able to do the usual things, such as displaying the username in the title / navigation bar (by the way), and currently I am doing this using the Jade view mechanism, but I donβt like mixing using Jade to view the mechanism for some 'bindings data and Angular for others.
Now I know that I could easily make an api endpoint call to node that returns req.user as JSON, but this seems like an ugly solution, as I would hit that endpoint every time there is (this is not SPA )
So, my question basically consists in the following: can I get a registered user in my Angular views so that I can execute all my client side, data binding, instead of any server part (with Jade view engine) and some client side with Angular?
Note. There are no code snippets, because everything actually works as intended, I just hope for a better alternative than what I have.
source share