refactor login with User factory