I am building a website where users can view posts.
The posts are publicly available. The requirement is that i need to check whether the user is logged in on every user action.
For example, a user hits my website url www.mysite.com and views a post. The user is not logged in at this point. The user tries to like the post. Before the method for like is executed, i need to execute a method to check if the user is logged in. If not logged in, show login box. Same is the case for all user actions.
function likePost() {
checkUserLogin();
...
}
function commentPost() {
checkUserLogin();
...
}
Is there a better way to do this in angularjs. Something like 'beforefilter' in rails?