Fixed ensureAuthenticated function and now a user can only access pages for their role, trying to access another role's pages will redirect them to the home page.