implemented function that allows users to access a route if logged in