mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-23 16:38:45 +01:00
prompt for installation id and download license
This commit is contained in:
parent
c639186c60
commit
30a2301697
@ -172,23 +172,40 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var licenseString = JSON.stringify(license, null, 2);
|
||||
var licenseBlob = new Blob([licenseString]);
|
||||
var installationId = prompt("Enter your installation id");
|
||||
if (!installationId || installationId === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
window.navigator.msSaveBlob(licenseBlob, 'bitwarden_organization_license.json');
|
||||
}
|
||||
else {
|
||||
var a = window.document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(licenseBlob, { type: 'text/plain' });
|
||||
a.download = 'bitwarden_premium_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);
|
||||
}
|
||||
apiService.organizations.getLicense({
|
||||
id: $state.params.orgId,
|
||||
installationId: installationId
|
||||
}, function (license) {
|
||||
var licenseString = JSON.stringify(license, null, 2);
|
||||
var licenseBlob = new Blob([licenseString]);
|
||||
|
||||
// IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
window.navigator.msSaveBlob(licenseBlob, 'bitwarden_organization_license.json');
|
||||
}
|
||||
else {
|
||||
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() {
|
||||
|
@ -59,6 +59,7 @@
|
||||
_service.organizations = $resource(_apiUri + '/organizations/:id', {}, {
|
||||
get: { 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: {} },
|
||||
post: { method: 'POST', params: {} },
|
||||
put: { method: 'POST', params: { id: '@id' } },
|
||||
|
Loading…
Reference in New Issue
Block a user