UNPKG

zettapi_client

Version:

Admin panel and client-side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project.

40 lines (37 loc) 1.44 kB
app.directive('zlReset', function () { return { restrict: 'E', scope: { item: '=?', zlClass: '@?' }, replace: false, templateUrl: 'directives/auth/reset/reset.html', controller: function ($scope, $auth, $location, $interpolate, blockUI, zapi) { if (typeof $scope.zlClass === 'undefined') $scope.zlClass = "form-control"; $scope.useInputLarge = zapi.useInputLarge; $scope.reset = function (item) { if ($scope.validateReset(item)) return; blockUI.start($interpolate("{{'api.services.auth.resetPasswordLoad' | translate}}")($scope)); $auth.resetPassword(item.email, item.username).then(function (response) { swal({ title: $interpolate("{{'api.services.auth.resetPasswordSuccessTitle' | translate}}")($scope), text: $interpolate("{{'api.services.auth.resetPasswordSuccessContent' | translate}}")($scope), type: "success" }); $location.path("/"); }).catch(function (response) { swal($interpolate("{{'api.services.auth.resetPasswordErrorTitle' | translate}}")($scope), response.data, "error"); }).finally(function () { blockUI.stop(); }); }; $scope.validateReset = function (item) { if (!item) return true; if (!item.email) return true; if (!item.username) return true; return false; }; } }; });