Fix fatal errors caused when access is checked without a user loaded in js.php

Related to #4202