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.

43 lines
1.2 KiB

  1. 'use strict';
  2. angular.module('app.signup', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/signup', {
  5. templateUrl: 'views/signup/signup.html',
  6. controller: 'SignupCtrl'
  7. });
  8. }])
  9. .controller('SignupCtrl', function($scope, $http, $routeParams) {
  10. $scope.user = {};
  11. $scope.doLogin = function() {
  12. console.log('Doing login', $scope.user);
  13. $http({
  14. url: urlapi + 'signup',
  15. method: "POST",
  16. data: $scope.user
  17. })
  18. .then(function(response) {
  19. console.log("response: ");
  20. console.log(response.data);
  21. if (response.data.success == true)
  22. {
  23. localStorage.setItem("cr_webapp_token", response.data.token);
  24. localStorage.setItem("cr_webapp_userdata", JSON.stringify(response.data.user));
  25. window.location.reload();
  26. }else{
  27. console.log("signup failed");
  28. toastr.error('Signup failed');
  29. }
  30. },
  31. function(response) { // optional
  32. // failed
  33. console.log(response);
  34. });
  35. };
  36. });