refactor: replaceRenewCheck only fire on Tools > Registration

This commit is contained in:
Zack Spear
2024-02-02 10:39:19 -08:00
committed by Zack Spear
parent 5c2d84d8b4
commit 77eed36990
3 changed files with 16 additions and 26 deletions

View File

@@ -25,6 +25,7 @@ import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import useDateTimeHelper from '~/composables/dateTime';
import { useReplaceRenewStore } from '~/store/replaceRenew';
import { useServerStore } from '~/store/server';
import type { RegistrationItemProps } from '~/types/registration';
@@ -35,6 +36,7 @@ import UserProfileUptimeExpire from '~/components/UserProfile/UptimeExpire.vue';
const { t } = useI18n();
const replaceRenewCheckStore = useReplaceRenewStore();
const serverStore = useServerStore();
const {
authAction,
@@ -44,6 +46,7 @@ const {
flashVendor,
flashProduct,
keyActions,
keyfile,
regGuid,
regTm,
regTo,
@@ -191,6 +194,13 @@ const items = computed((): RegistrationItemProps[] => {
: []),
];
});
onBeforeMount(() => {
/** automatically check for replacement and renewal eligibility…will prompt user if eligible for a renewal / key re-roll for legacy keys */
if (guid.value && keyfile.value) {
replaceRenewCheckStore.check();
}
});
</script>
<template>

View File

@@ -6,7 +6,6 @@ import { useI18n } from 'vue-i18n';
import { useCallbackStore, useCallbackActionsStore } from '~/store/callbackActions';
import { useDropdownStore } from '~/store/dropdown';
import { useReplaceRenewStore } from '~/store/replaceRenew';
import { useServerStore } from '~/store/server';
import { useThemeStore } from '~/store/theme';
import type { Server } from '~/types/server';
@@ -22,7 +21,6 @@ const { t } = useI18n();
const callbackStore = useCallbackStore();
const dropdownStore = useDropdownStore();
const replaceRenewCheckStore = useReplaceRenewStore();
const serverStore = useServerStore();
const { callbackData } = storeToRefs(useCallbackActionsStore());
@@ -94,8 +92,6 @@ onBeforeMount(() => {
if (callbackData.value) {
return console.debug('Renew callback detected, skipping auto check for key replacement, renewal eligibility, and OS Update.');
}
// automatically check for replacement and renewal eligibility…will prompt user if eligible for a renewal / key re-roll for legacy keys
replaceRenewCheckStore.check();
} else {
console.warn('A valid keyfile and USB Flash boot device are required to check for key renewals, key replacement eligibiliy, and OS update availability.');
}

View File

@@ -1,3 +1,9 @@
/**
* Change the trigger of this to happen on when on Tools > Registration
*
* New key replacement, should happen also on server side.
* Cron to run hourly, check on how many days are left until regExp…within X days then allow request to be done
*/
import {
CheckCircleIcon,
XCircleIcon,
@@ -12,9 +18,7 @@ import {
type KeyLatestResponse,
type ValidateGuidResponse,
} from '~/composables/services/keyServer';
// import { WebguiNotify } from '~/composables/services/webgui';
import { useCallbackStore } from '~/store/callbackActions';
// import { useInstallKeyStore } from '~/store/installKey';
import { useServerStore } from '~/store/server';
import type { UiBadgeProps } from '~/types/ui/badge';
import BrandLoadingWhite from '~/components/Brand/LoadingWhite.vue';
@@ -37,7 +41,6 @@ export const REPLACE_CHECK_LOCAL_STORAGE_KEY = 'unraidReplaceCheck';
export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
const callbackStore = useCallbackStore();
// const installKeyStore = useInstallKeyStore();
const serverStore = useServerStore();
const guid = computed(() => serverStore.guid);
@@ -182,25 +185,6 @@ export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
undefined,
'forUpc',
);
// setRenewStatus('installing');
// await installKeyStore.install({
// keyUrl: keyLatestResponse.license,
// type: 'renew',
// }).then(() => {
// setRenewStatus('installed');
// // reset the validation response so we can check again on the subsequent page load. Will also prevent the keyfile from being installed again on page refresh.
// purgeValidationResponse();
// /** @todo this doesn't work */
// WebguiNotify({
// cmd: 'add',
// csrf_token: serverStore.csrf,
// e: 'Keyfile Renewed and Installed (event)',
// s: 'Keyfile Renewed and Installed (subject)',
// d: 'While license keys are perpetual, certain keyfiles are not. Your keyfile has automatically been renewed and installed in the background. Thanks for your support!',
// m: 'Your keyfile has automatically been renewed and installed in the background. Thanks for your support!',
// })
// });
}
}
} catch (err) {