samedi 24 décembre 2016

Load different templates based on user login status

I am working on an application where there is a generic welcome page and then there are views which are visible only to the logged in / authorized users.

Now, to achieve that I am loading my angular application and then checking the cookie from angular and if the user is not logged in then redirecting the user to the /login route with a form and then if the user is successfully logged in then it can access the restricted views of the application.

My question is do I need to load the whole angular application each time even to show the welcome page. I think it can make the application slow as well as loading too many extra code. For example what if user just comes to the welcome screen and does nothing? or he is not authenticated user and he is signing up for the first time? wouldn't it will be better if I just load a lightweight version of the page with just my login module of the angularjs and then load a totally different template once the user is logged in?

What is recommended approach in these scenarios?




Aucun commentaire:

Enregistrer un commentaire