Advertisement
Guest User

Untitled

a guest
Jun 8th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. (function () {
  2. 'use strict';
  3.  
  4. angular
  5. .module('app.user')
  6. .controller('SignupController', SignupController);
  7.  
  8. SignupController.$inject = ['$auth', 'toastr', '$state'];
  9. function SignupController($auth, toastr, $state) {
  10. var vm = this;
  11. vm.signup = signup;
  12. vm.user = {
  13. username: '',
  14. email: '',
  15. password: ''
  16. };
  17. vm.error = '';
  18.  
  19. activate();
  20.  
  21. ////////////////
  22.  
  23. function activate() {
  24.  
  25. }
  26.  
  27. function signup() {
  28. $auth.signup(vm.user)
  29. .then(function () {
  30. vm.error = '';
  31. toastr.success('You have successfully signed up!');
  32. $state.go('signup_success');
  33. })
  34. .catch(function (error) {
  35. if (error.status == 400) {
  36. // user already exists
  37. vm.error = 'user with same username or email is already registered';
  38. } else {
  39. // generic error message
  40. vm.error = 'user with same username or email is already registered';
  41. }
  42. toastr.error(error.data, error.status);
  43. });
  44. }
  45. }
  46. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement