refactor login (PR #14803)

GitHub