refactor login, abstract root state