Refactor code and extract password link to avoid code duplication