admin: can renew the PKI from interface

This commit is contained in:
nemunaire 2020-01-21 18:51:43 +01:00
parent 5c17dd4605
commit 34a2370236
2 changed files with 12 additions and 6 deletions

View file

@ -593,11 +593,13 @@ angular.module("FICApp")
})
.controller("PKIController", function($scope, $rootScope, Certificate, CACertificate, Team, $location, $http) {
var ts = Date.now() - Date.now() % 86400000;
var ts = Date.now() - Date.now() % 86400000;
var d = new Date(ts);
$scope.notBefore = d.toISOString();
var f = new Date(ts + 3 * 86400000);
$scope.notAfter = f.toISOString();
$scope.newca = {
notAfter: f.toISOString(),
notBefore: d.toISOString(),
};
$scope.teams = Team.query();
$scope.certificates = Certificate.query();
@ -636,12 +638,15 @@ angular.module("FICApp")
};
$scope.generateCA = function() {
$http.post("/api/ca/new", {"notbefore": $scope.notBefore, "notafter": $scope.notAfter}).then(function() {
$http.post("/api/ca/new", $scope.newca).then(function() {
$scope.ca = CACertificate.get();
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when generating CA:', response.data.errmsg);
});
};
$scope.renewCA = function() {
$scope.ca = {};
};
$scope.generateCert = function() {
$http.post("/api/certs").then(function() {