refactoring Auto login implementation.