Refactor UAM secret code for uam.php