app.directive('zlActivation', function () {
  return {
    restrict: 'E',
    scope: true,
    replace: false,
    templateUrl: 'directives/activation/activation.html',
    controller: function ($scope, $auth, $location, $routeParams) {
      $scope.user = null;

      $auth.activateAccount($routeParams.code, function (err, user) {
        if (err) {
          return $location.path('/');
        }
        $scope.user = user;
      });


      $scope.changePassword = function (newPassword1, newPassword2) {
        $auth.changePassword($scope.user, newPassword1, newPassword2, function (err) {
          if (!err) {
            return $location.path('/');
          }
        });
      };
    }
  };
});
