Rewrite login process in preparation for both forge and netty.