fix routing when the path has optional trailing arguments.
only set drupal uid in session when user is authenticated.