fix the error handling when user is not authenticated