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() {

View File

@ -111,6 +111,7 @@
<span class="badge badge-success" ng-if="ca.version">Générée</span>
<span class="badge badge-danger" ng-if="!ca.version">Introuvable</span>
<button type="button" ng-click="generateCA()" class="float-right btn btn-sm btn-primary" ng-if="!ca.version"><span class="glyphicon glyphicon-certificate" aria-hidden="true"></span> Générer</button>
<button type="button" ng-click="renewCA()" class="float-right btn btn-sm btn-primary" ng-if="ca.version"><span class="glyphicon glyphicon-certificate" aria-hidden="true"></span> Regénérer</button>
</h2>
<div class="alert alert-info" ng-if="!ca.version">
@ -119,13 +120,13 @@
<div class="form-group row">
<label for="CAnotBefore" class="col-sm-3 col-form-label">Début de validité</label>
<div class="col-sm-9">
<input type="text" class="form-control form-control-sm" id="CAnotBefore" ng-model="notBefore">
<input type="text" class="form-control form-control-sm" id="CAnotBefore" ng-model="newca.notBefore">
</div>
</div>
<div class="form-group row">
<label for="CAnotAfter" class="col-sm-3 col-form-label">Fin de validité</label>
<div class="col-sm-9">
<input type="text" class="form-control form-control-sm" id="CAnotAfter" ng-model="notAfter">
<input type="text" class="form-control form-control-sm" id="CAnotAfter" ng-model="newca.notAfter">
</div>
</div>
</div>