Added a conditional for automatic redirection when the user is already logged in