Advertisement
Guest User

Untitled

a guest
Feb 15th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. angular.module('app')
  2.  
  3. .factory('AuthService', ['User', '$q', '$rootScope', function(User, $q, $rootScope) {
  4.  
  5. function register(email, password) {
  6. return User
  7. .create({
  8. email: email,
  9. password: password
  10. })
  11. .$promise;
  12. }
  13.  
  14. function login(email, password) {
  15. return User
  16. .login({email: email, password: password})
  17. .$promise
  18. .then(function(response) {
  19. $rootScope.currentUser = {
  20. id: response.user.id,
  21. tokenId: response.id,
  22. email: email
  23. };
  24. });
  25. }
  26.  
  27. return {
  28. register: register,
  29. login: login
  30. };
  31.  
  32. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement