You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

signup.controller.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. angular.module('app')
  2. .controller('SignUpController', ['$scope', '$state', '$mdDialog', 'luticateAuthUsers',
  3. function($scope, $state, $mdDialog, luticateAuthUsers) {
  4. $scope.user = {
  5. Username: "",
  6. Passwords: {
  7. Password1: "",
  8. Password2: ""
  9. },
  10. Firstname: "",
  11. Lastname: "",
  12. Email: ""
  13. };
  14. $scope.error = null;
  15. $scope.signUp = function () {
  16. $scope.error = null;
  17. if ($scope.user.Passwords.Password1 != $scope.user.Passwords.Password2) {
  18. $scope.error = {
  19. Data: "Passwords do not match"
  20. };
  21. return;
  22. }
  23. if ($scope.user.Username == "" || $scope.user.Firstname == ""
  24. || $scope.user.Lastname == "" || $scope.user.Email == "") {
  25. return;
  26. }
  27. luticateAuthUsers.add({
  28. username: $scope.user.Username,
  29. password: $scope.user.Passwords.Password1,
  30. firstname: $scope.user.Firstname,
  31. lastname: $scope.user.Lastname,
  32. email: $scope.user.Email
  33. }).then(function(data)
  34. {
  35. $state.go("login");
  36. }, function (error) {
  37. $scope.error = error;
  38. })
  39. };
  40. }]);