Skip to content

Commit cff6c4d

Browse files
committed
- prevent wildcard generation when not using Cloudflare dns
- fix cloudflare token required logic
1 parent 077cf75 commit cff6c4d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

frontend/js/app/nginx/certificates/form.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<div class="col-sm-12 col-md-12 cloudflare">
3535
<div class="form-group">
3636
<label class="form-label">CloudFlare DNS API Token <span class="form-required">*</span></label>
37-
<input type="text" name="meta[cloudflare_token]" class="form-control" id="cloudflare_token" required>
37+
<input type="text" name="meta[cloudflare_token]" class="form-control" id="cloudflare_token">
3838
</div>
3939
</div>
4040

frontend/js/app/nginx/certificates/form.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,50 @@ module.exports = Mn.View.extend({
2222
other_certificate_key: '#other_certificate_key',
2323
other_intermediate_certificate: '#other_intermediate_certificate',
2424
cloudflare_switch: 'input[name="meta[cloudflare_use]"]',
25+
cloudflare_token: 'input[name="meta[cloudflare_token]"',
2526
cloudflare: '.cloudflare'
2627
},
2728

2829
events: {
2930
'change @ui.cloudflare_switch': function() {
3031
let checked = this.ui.cloudflare_switch.prop('checked');
31-
if (checked) {
32+
if (checked) {
33+
this.ui.cloudflare_token.prop('required', 'required');
3234
this.ui.cloudflare.show();
33-
} else {
34-
this.ui.cloudflare.hide();
35+
} else {
36+
this.ui.cloudflare_token.prop('required', false);
37+
this.ui.cloudflare.hide();
3538
}
3639
},
3740
'click @ui.save': function (e) {
3841
e.preventDefault();
3942

4043
if (!this.ui.form[0].checkValidity()) {
4144
$('<input type="submit">').hide().appendTo(this.ui.form).click().remove();
42-
$(this).addClass('btn-loading');
45+
$(this).removeClass('btn-loading');
4346
return;
4447
}
4548

4649
let view = this;
4750
let data = this.ui.form.serializeJSON();
4851
data.provider = this.model.get('provider');
4952

53+
54+
55+
let domain_err = false;
56+
if (!data.meta.cloudflare_use) {
57+
data.domain_names.split(',').map(function (name) {
58+
if (name.match(/\*/im)) {
59+
domain_err = true;
60+
}
61+
});
62+
}
63+
64+
if (domain_err) {
65+
alert('Cannot request Let\'s Encrypt Certificate for wildcard domains when not using CloudFlare DNS');
66+
return;
67+
}
68+
5069
// Manipulate
5170
if (typeof data.meta !== 'undefined' && typeof data.meta.letsencrypt_agree !== 'undefined') {
5271
data.meta.letsencrypt_agree = !!data.meta.letsencrypt_agree;

0 commit comments

Comments
 (0)