A new function checks if an user  is loggedIn if not it redirects the user to the main page