Registration and authentication in Angular.js