Projekt

Obecné

Profil

« Předchozí | Další » 

Revize a857e1ac

Přidáno uživatelem Jan Pašek před asi 4 roky(ů)

Re #8583 Added self-signed checkbox when creating certificates

Zobrazit rozdíly:

static/create_certificate.html
13 13
                <div class="form-group">
14 14
                    <td><label for="CA">Certificate Authority:</label></td>
15 15
                    <td class="pl-3">
16
                        <select v-model="certificateData.CA" name="CA" id="CA" class="form-control">
17
                            <option value=null>Self-Signed</option>
16
                        <select v-model="certificateData.CA" name="CA" id="CA" class="form-control" :disabled="isSelfSigned">
17
                            <option value=null disabled selected>-- Select issuer --</option>
18 18
                            <option is="ca-select-item"
19 19
                                    v-for="ca in authorities"
20 20
                                    v-bind:ca="ca"
21 21
                                    v-bind:key="ca.id"></option>
22 22
                        </select>
23 23
                    </td>
24
                    <td style="padding-left: 37px">
25
                        <input class="form-check-input" :disabled="authorities.length === 0" v-model="isSelfSigned" type="checkbox" id="isSelfSigned" name="isSelfSigned" value="self-signed">
26
                        <label class="form-check-label" for="isSelfSigned">Self-signed</label><br>
27
                    </td>
24 28
                </div>
25 29
            </tr>
26 30
            <tr>
static/js/create_certificate.js
5 5
            data: {
6 6
                notBefore: "",
7 7
                notAfter: "",
8
                isSelfSigned: false,
8 9
                // available certificate authorities
9 10
                authorities: [],
10 11
                // data of the selected certificate authorities to be displayed in the form
......
50 51
                onCreateCertificate: function () {
51 52
                    // validate input data
52 53
                    // - validate if subject CN is filled in
54
                    if(!this.isSelfSigned && this.certificateData.CA == null)
55
                    {
56
                        alert("Issuer must be selected or 'Self-signed' option must be checked!");
57
                        return;
58
                    }
53 59
                    if(this.certificateData.subject.CN === "") {
54 60
                        alert("CN field must be filled in!"); // TODO highlight the field
55 61
                        return;
......
74 80
            },
75 81
            // data watches
76 82
            watch: {
83
                authorities: function (val, oldVal) {
84
                    this.isSelfSigned = val.length === 0;
85
                },
86
                isSelfSigned: function (val, oldVal) {
87
                    if (val) {
88
                        this.certificateData.CA = null;
89
                    }
90
                },
77 91
                // if the selected CA is changed, the Issuer input fileds must be filled in
78 92
                'certificateData.validityDays': function (val, oldVal) {
79 93
                    var endDate = new Date(new Date().getTime()+(val*24*60*60*1000));
......
123 137
                createCertificateApp.authorities = response.data["data"];
124 138
            }
125 139
            else
126
                console.log("Error occurred while fetching list of available certificate authorities");
140
            {
141
                createCertificateApp.authorities = []
142
            }
127 143
        })
128 144
        .catch(function (error) {
129 145
            console.log(error);

Také k dispozici: Unified diff