+
diff --git a/store/account.ts b/store/account.ts
index b8b63c1f7..3fd1ef617 100644
--- a/store/account.ts
+++ b/store/account.ts
@@ -16,10 +16,40 @@ export const useAccountStore = defineStore('account', () => {
// State
const accountAction = ref();
+ const accountActionHide = ref(false);
const accountActionStatus = ref<'failed' | 'ready' | 'success' | 'updating'>('ready');
const username = ref('');
+ // Getters
+ const accountActionType = computed(() => accountAction.value?.type);
+ const accountActionStatusCopy = computed((): { text: string; } => {
+ switch (accountActionStatus.value) {
+ case 'ready':
+ return {
+ text: 'Ready to update Connect account configuration',
+ };
+ case 'updating':
+ return {
+ text: accountAction.value?.type === 'signIn'
+ ? `Signing in ${accountAction.value.user?.preferred_username}...`
+ : `Signing out ${username.value}...`,
+ };
+ case 'success':
+ return {
+ text: accountAction.value?.type === 'signIn'
+ ? `${accountAction.value.user?.preferred_username} Signed In Successfully`
+ : `${username.value} Signed Out Successfully`,
+ };
+ case 'failed':
+ return {
+ text: accountAction.value?.type === 'signIn'
+ ? 'Sign In Failed'
+ : 'Sign Out Failed',
+ };
+ }
+ });
+
// Actions
const recover = () => {
console.debug('[accountStore.recover]');
@@ -98,6 +128,13 @@ export const useAccountStore = defineStore('account', () => {
}),
};
+ if (!serverStore.registered && !accountAction.value.user) {
+ console.debug('[accountStore.updatePluginConfig] Not registered skipping sign out');
+ accountActionHide.value = true;
+ accountActionStatus.value = 'success';
+ return;
+ }
+
try {
const response = await WebguiUpdate
.formUrl({
@@ -122,43 +159,14 @@ export const useAccountStore = defineStore('account', () => {
}
};
- const accountActionStatusCopy = computed((): { text: string; } => {
- switch (accountActionStatus.value) {
- case 'ready':
- return {
- text: 'Ready to update Connect account configuration',
- };
- case 'updating':
- return {
- text: accountAction.value?.type === 'signIn'
- ? `Signing in ${accountAction.value.user?.preferred_username}...`
- : `Signing out ${username.value}...`,
- };
- case 'success':
- return {
- text: accountAction.value?.type === 'signIn'
- ? `${accountAction.value.user?.preferred_username} Signed In Successfully`
- : `${username.value} Signed Out Successfully`,
- };
- case 'failed':
- return {
- text: accountAction.value?.type === 'signIn'
- ? 'Sign In Failed'
- : 'Sign Out Failed',
- };
- }
- });
-
- watch(accountActionStatus, (newV, oldV) => {
- console.debug('[accountActionStatus.watch]', newV, oldV);
- });
-
return {
// State
accountAction,
+ accountActionHide,
accountActionStatus,
// Getters
accountActionStatusCopy,
+ accountActionType,
// Actions
recover,
replace,
diff --git a/store/callbackActions.ts b/store/callbackActions.ts
index f70675c7f..b90632515 100644
--- a/store/callbackActions.ts
+++ b/store/callbackActions.ts
@@ -70,22 +70,15 @@ export const useCallbackActionsStore = defineStore(
watch(callbackStatus, (newVal, _oldVal) => {
console.debug('[callbackStatus]', newVal);
if (newVal === 'ready') {
- console.debug('[callbackStatus]', newVal, 'addEventListener');
window.addEventListener('beforeunload', preventClose);
}
- // removing query string once actions are done so users can't refresh the page and go through the same actions
if (newVal !== 'ready') {
- console.debug('[callbackStatus]', newVal, 'removeEventListener');
window.removeEventListener('beforeunload', preventClose);
- console.debug('[callbackStatus] replace history w/o query');
+ // removing query string once actions are done so users can't refresh the page and go through the same actions
window.history.replaceState(null, '', window.location.pathname);
}
});
- watch(callbackData, () => {
- console.debug('[callbackData] watch', callbackData.value);
- });
-
return {
redirectToCallbackType,
callbackData,