diff --git a/lib/extensions/admin/account.html b/lib/extensions/admin/account.html index a0405a6..99537f6 100644 --- a/lib/extensions/admin/account.html +++ b/lib/extensions/admin/account.html @@ -27,17 +27,23 @@
If your DNS host supports ANAME records, please use those instead of CNAMEs.
+If CNAMEs are not supported, set an A record to {{ site.deviceDomainA }}.
diff --git a/lib/extensions/admin/js/account.js b/lib/extensions/admin/js/account.js
index a11a38c..319b581 100644
--- a/lib/extensions/admin/js/account.js
+++ b/lib/extensions/admin/js/account.js
@@ -17,6 +17,10 @@
}
}
+ var dnsRecords = {
+ "telebit.ppl.family": "178.128.3.196"
+ , "telebit.cloud": "46.101.97.218"
+ };
var vueData = {
claims: []
, domains: []
@@ -25,17 +29,31 @@
, newEmail: null
, hasAccount: false
, token: null
+ , site: { deviceDomain: document.location.hostname, deviceDomainA: dnsRecords[document.location.hostname] }
};
var app = new Vue({
el: '.v-app'
, data: vueData
, methods: {
challengeDns: function () {
+ // we could do a checkbox
+ var wildcard = vueData.newDomainWildcard || false;
+ if (!/(\*\.)?[a-z0-9][a-z0-9\.\-_]\.[a-z0-9]{2,}/.test(vueData.newDomain)) {
+ window.alert("invalid domain name '" + vueData.newDomain + "'");
+ return;
+ }
+ // we can just detect by text
+ if ('*.' === vueData.newDomain.slice(0, 2)) {
+ vueData.newDomain = vueData.newDomain.slice(2);
+ wildcard = true;
+ }
return oauth3.request({
url: 'https://api.' + location.hostname + '/api/telebit.cloud/account/authorizations/new'
, method: 'POST'
, session: session
- , data: { type: 'dns', value: vueData.newDomain, wildcard: vueData.newDomainWildcard }
+ , data: { type: 'dns', value: vueData.newDomain, wildcard: wildcard }
+ }).then(function (resp) {
+ vueData.claims.unshift(resp.data.claim);
});
}
, checkDns: function (claim) {