Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('app')
- .factory('AuthService', ['User', '$q', '$rootScope', function(User, $q, $rootScope) {
- function register(email, password) {
- return User
- .create({
- email: email,
- password: password
- })
- .$promise;
- }
- function login(email, password) {
- return User
- .login({email: email, password: password})
- .$promise
- .then(function(response) {
- $rootScope.currentUser = {
- id: response.user.id,
- tokenId: response.id,
- email: email
- };
- });
- }
- return {
- register: register,
- login: login
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement