prompt for installation id and download license

This commit is contained in:
Kyle Spearrin 2017-08-15 16:18:31 -04:00
parent c639186c60
commit 30a2301697
2 changed files with 34 additions and 16 deletions

View File

@ -172,23 +172,40 @@
return; return;
} }
var licenseString = JSON.stringify(license, null, 2); var installationId = prompt("Enter your installation id");
var licenseBlob = new Blob([licenseString]); if (!installationId || installationId === '') {
return;
}
// IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx apiService.organizations.getLicense({
if (window.navigator.msSaveOrOpenBlob) { id: $state.params.orgId,
window.navigator.msSaveBlob(licenseBlob, 'bitwarden_organization_license.json'); installationId: installationId
} }, function (license) {
else { var licenseString = JSON.stringify(license, null, 2);
var a = window.document.createElement('a'); var licenseBlob = new Blob([licenseString]);
a.href = window.URL.createObjectURL(licenseBlob, { type: 'text/plain' });
a.download = 'bitwarden_premium_license.json'; // IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
document.body.appendChild(a); if (window.navigator.msSaveOrOpenBlob) {
// IE: "Access is denied". window.navigator.msSaveBlob(licenseBlob, 'bitwarden_organization_license.json');
// ref: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access }
a.click(); else {
document.body.removeChild(a); var a = window.document.createElement('a');
} a.href = window.URL.createObjectURL(licenseBlob, { type: 'text/plain' });
a.download = 'bitwarden_organization_license.json';
document.body.appendChild(a);
// IE: "Access is denied".
// ref: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
a.click();
document.body.removeChild(a);
}
}, function (err) {
if (err.status === 400) {
toastr.error("Invalid installation id.");
}
else {
toastr.error("Unable to generate license.");
}
});
}; };
function load() { function load() {

View File

@ -59,6 +59,7 @@
_service.organizations = $resource(_apiUri + '/organizations/:id', {}, { _service.organizations = $resource(_apiUri + '/organizations/:id', {}, {
get: { method: 'GET', params: { id: '@id' } }, get: { method: 'GET', params: { id: '@id' } },
getBilling: { url: _apiUri + '/organizations/:id/billing', method: 'GET', params: { id: '@id' } }, getBilling: { url: _apiUri + '/organizations/:id/billing', method: 'GET', params: { id: '@id' } },
getLicense: { url: _apiUri + '/organizations/:id/license', method: 'GET', params: { id: '@id' } },
list: { method: 'GET', params: {} }, list: { method: 'GET', params: {} },
post: { method: 'POST', params: {} }, post: { method: 'POST', params: {} },
put: { method: 'POST', params: { id: '@id' } }, put: { method: 'POST', params: { id: '@id' } },