3 |
3 |
var createCertificateApp = new Vue({
|
4 |
4 |
el: "#create-certificate-content",
|
5 |
5 |
data: {
|
|
6 |
notBefore: "",
|
|
7 |
notAfter: "",
|
6 |
8 |
// available certificate authorities
|
7 |
9 |
authorities: [],
|
8 |
10 |
// data of the selected certificate authorities to be displayed in the form
|
... | ... | |
26 |
28 |
OU: "",
|
27 |
29 |
emailAddress: ""
|
28 |
30 |
},
|
29 |
|
notBefore: "",
|
30 |
|
notAfter: "",
|
|
31 |
validityDays: 30,
|
31 |
32 |
usage: {
|
32 |
33 |
CA: false,
|
33 |
34 |
authentication: false,
|
... | ... | |
40 |
41 |
// actions to be performed when the page is loaded
|
41 |
42 |
// - initialize notBefore and notAfter with current date and current date + 1 month respectively
|
42 |
43 |
mounted () {
|
43 |
|
this.certificateData.notBefore = new Date().toDateInputValue(); // init notBefore to current date
|
|
44 |
this.notBefore = new Date().toDateInputValue(); // init notBefore to current date
|
44 |
45 |
var endDate = new Date(new Date().getTime()+(30*24*60*60*1000));
|
45 |
|
this.certificateData.notAfter = endDate.toDateInputValue(); // init notAfter to notBefore + 30 days
|
|
46 |
this.notAfter = endDate.toDateInputValue(); // init notAfter to notBefore + 30 days
|
46 |
47 |
},
|
47 |
48 |
methods: {
|
48 |
49 |
// handle certificate creation request
|
... | ... | |
53 |
54 |
alert("CN field must be filled in!"); // TODO highlight the field
|
54 |
55 |
return;
|
55 |
56 |
}
|
56 |
|
// - validate if notAfter is > notBefore
|
57 |
|
if(new Date(this.certificateData.notBefore) > new Date(this.certificateData.notAfter)) {
|
58 |
|
alert("notBefore must chronologically lower than notAfter"); // TODO highlight the field
|
59 |
|
return;
|
60 |
|
}
|
61 |
57 |
// send the request and handle response
|
62 |
58 |
axios.post(API_URL + "certificates", this.certificateData)
|
63 |
59 |
.then(function (response) {
|
... | ... | |
79 |
75 |
// data watches
|
80 |
76 |
watch: {
|
81 |
77 |
// if the selected CA is changed, the Issuer input fileds must be filled in
|
|
78 |
'certificateData.validityDays': function (val, oldVal) {
|
|
79 |
var endDate = new Date(new Date().getTime()+(val*24*60*60*1000));
|
|
80 |
this.notAfter = endDate.toDateInputValue(); // init notAfter to today + validityDays
|
|
81 |
},
|
82 |
82 |
'certificateData.CA': function (val, oldVal) {
|
83 |
83 |
// self-signed certificate - all fields are empty
|
84 |
84 |
if (val === "null" || val == null) {
|
Re #8475 - Changed notBefore & notAfter to validityDays