refactor login auth