app.controller('SignupCtrl', function($scope, $http, $location, CheckAuth) {
  CheckAuth().then(function(res) {
    $location.path('/user');
  }, function() {});
  $scope.formUser = {};
  $http.get('/sys/captcha/new', null).then(function(res) {
    $scope.cTestImg = '/sysimg/captcha/' + res.data.img;
  }, function(res) {

  });
  $scope.signupSubmit = function() {
    if ($scope.formUser.password && $scope.formUser.password === $scope.formUser.passcheck) {
      $http.post('/sys/signup', $scope.formUser).then(function(res) {
        $scope.signupStatus = res.status;
        $location.path('/login/new');

      },function(res) {
        $scope.signupStatus = res.status;
        $scope.signupError = res.data.error;
        $http.get('/sys/captcha/new', null).then(function(res) {
          $scope.cTestImg = '/sysimg/captcha/' + res.data.img;
        }, function(res) {

        });
      });
    }
  };
});
