SYNC: renew license from set license page

This commit is contained in:
SPRINX0\prochazka
2025-07-14 13:41:36 +02:00
committed by Diflow
parent b7e6838d26
commit 16d2a9bf99
3 changed files with 18 additions and 7 deletions

View File

@@ -209,7 +209,7 @@ module.exports = {
},
saveLicenseKey_meta: true,
async saveLicenseKey({ licenseKey, forceSave = false }) {
async saveLicenseKey({ licenseKey, forceSave = false, tryToRenew = false }) {
if (!forceSave) {
const decoded = jwt.decode(licenseKey?.trim());
if (!decoded) {
@@ -221,10 +221,21 @@ module.exports = {
const { exp } = decoded;
if (exp * 1000 < Date.now()) {
return {
status: 'error',
errorMessage: 'License key is expired',
};
let renewed = false;
if (tryToRenew) {
const newLicenseKey = await tryToGetRefreshedLicense(licenseKey);
if (newLicenseKey.status == 'ok') {
licenseKey = newLicenseKey.token;
renewed = true;
}
}
if (!renewed) {
return {
status: 'error',
errorMessage: 'License key is expired',
};
}
}
}

View File

@@ -50,7 +50,7 @@
on:click={async e => {
sessionStorage.setItem('continueTrialConfirmed', '1');
const { licenseKey } = e.detail;
const resp = await apiCall('config/save-license-key', { licenseKey });
const resp = await apiCall('config/save-license-key', { licenseKey, tryToRenew: true });
if (resp?.status == 'ok') {
internalRedirectTo(isOneOfPage('admin-license') ? '/admin.html' : '/index.html');
} else {

View File

@@ -84,7 +84,7 @@
}
.wrap {
margin-top: 20vh;
margin-top: 5vh;
}
.heading {