add loginMiddleware server only export and add test