zettapi_client
Version:
Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project
33 lines (27 loc) • 849 B
JavaScript
app.directive('zlReset', function (zapiPath) {
return {
restrict: 'E',
scope: {
item: '=',
zlClass: '@?'
},
replace: false,
templateUrl: zapiPath + '/directives/reset/reset.html',
controller: function ($scope, $auth, $location, blockUI) {
if (typeof $scope.zlClass === 'undefined') $scope.zlClass = "form-control input-lg";
$scope.reset = function (item) {
if ($scope.validateReset(item)) return;
$auth.resetPassword(item.email, item.username, function (err) {
if (err) return swal("Atenção", err, "warning");
$location.path("/");
});
};
$scope.validateReset = function (item) {
if (!item) return true;
if (!item.email) return true;
if (!item.username) return true;
return false;
};
}
};
});