Refactor serveLogin.