Problem with promise going to error even though it works

Hey everybody!
I’m working on an app which contacts a rest api, there is a login and a register view for now, the register works fine but the register misbehaves.

When I fill all the fields and click on register, the app actually register the user (he appears in the database) but I still get the error as if there was a problem and I can’t figure out why it’s doing this.

Here is the controller.js code used:
.controller(‘RegisterCtrl’, function($scope, AuthService, $ionicPopup, $state) {
$scope.player = {
firstName: ‘’,
lastName: ‘’,
password: ‘’,
email: ‘’
};

  $scope.signup = function() {
	AuthService.register($scope.player).then(function(msg) {
	  $state.go('outside.login');
	  var alertPopup = $ionicPopup.alert({
		title: 'Enregistrement effectué !',
		template: msg
	  });
	}, function(errMsg) {
	  var alertPopup = $ionicPopup.alert({
		title: 'Erreur lors de l\'enregistrement !',
		template: errMsg
	  });
	});
  };
})

Here is the services.js part (check the “var register” part):
.service(‘AuthService’, function($q, $http, API_ENDPOINT) {
var LOCAL_TOKEN_KEY = ‘xxx’;
var isAuthenticated = false;
var authToken;

  function loadUserCredentials() {
	var token = window.localStorage.getItem(LOCAL_TOKEN_KEY);
	if (token) {
	  useCredentials(token);
	}
  }

  function storeUserCredentials(token) {
	window.localStorage.setItem(LOCAL_TOKEN_KEY, token);
	useCredentials(token);
  }

  function useCredentials(token) {
	isAuthenticated = true;
	authToken = token;

	// Set the token as header for your requests!
	$http.defaults.headers.common.Authorization = authToken;
  }

  function destroyUserCredentials() {
	authToken = undefined;
	isAuthenticated = false;
	$http.defaults.headers.common.Authorization = undefined;
	window.localStorage.removeItem(LOCAL_TOKEN_KEY);
  }

  var register = function(player) {
	return $q(function(resolve, reject) {
	  $http.post(API_ENDPOINT.url + '/playersignup', player).then(function(result) {
		if (result.data.succes) {
		  resolve(result.data.msg);
		} else {
		  reject(result.data.msg);
		}
	  });
	});
  };

  var login = function(player) {
	return $q(function(resolve, reject) {
	  $http.post(API_ENDPOINT.url + '/authenticate', player).then(function(result) {
		if (result.data.success) {
		  storeUserCredentials(result.data.token);
		  resolve(result.data.msg);
		} else {
		  reject(result.data.msg);
		}
	  });
	});
  };

  var logout = function() {
	destroyUserCredentials();
  };

  loadUserCredentials();

  return {
	login: login,
	register: register,
	logout: logout,
	isAuthenticated: function() {return isAuthenticated;},
  };
})

So when I click register, if there is an error or not I always get the popup alert with ‘Erreur lors de l’enregistrement !’ even when the user is created (and therefore the user is not sent to the login page).

If you need more code please let me know and I’ll add the other parts but from my understanding this is what I think is used for this.

Thanks for reading!