zettapi_client
Version:
Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project
45 lines (37 loc) • 929 B
JavaScript
app.directive('zlLogin', function (zapiPath) {
return {
restrict: 'E',
scope: true,
replace: false,
templateUrl: zapiPath + '/directives/login/login.html',
controller: function (blockUI, $auth, $location, $scope, $uibModalStack) {
$scope.login = function () {
if ($scope.validateLogin()) {
return;
}
$auth.login($scope.username, $scope.password, function (err) {
if (err) {
reset();
}
else {
$location.path('/profile');
$uibModalStack.dismissAll();
}
});
};
$scope.validateLogin = function () {
if (!$scope.username) {
return true;
}
if (!$scope.password) {
return true;
}
return false;
};
function reset() {
$scope.username = "";
$scope.password = "";
}
}
};
});