app.directive('zlReset', function () {
  return {
    restrict: 'E',
    scope: true,
    replace: false,
    templateUrl: 'directives/reset/reset.html',
    controller: function ($scope, $auth, $location, blockUI) {
      $scope.reset = function (item) {
        if ($scope.validateReset(item)) {
          return;
        }

        $auth.resetPassword(item.email, item.username, function (err) {
          if (!err) {
            return $location.path("/");
          }
        });
      };

      $scope.validateReset = function (item) {
        if (!item) {
          return true;
        }

        if (!item.email) {
          return true;
        }

        if (!item.username) {
          return true;
        }

        return false;
      };
    }
  };
});


