Refactor login with promises