Auth refactor

Refactor the authentication with promise.