Moved stuff around in authmiddleware