added login authentication and redirect handling