Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 76 additions & 54 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VITE_ACCOUNT=http://localhost:5555
VITE_CONNECT=https://connect.myunraid.net
VITE_UNRAID_NET=https://unraid.ddev.site
VITE_OS_RELEASES="https://releases.unraid.net/os"
VITE_CALLBACK_KEY=aNotSoSecretKeyUsedToObfuscateQueryParams
VITE_CALLBACK_KEY=Uyv2o8e*FiQe8VeLekTqyX6Z*8XonB
VITE_ALLOW_CONSOLE_LOGS=true
# Base font size in pixels for Tailwind CSS. Used by the tailwind-rem-to-rem plugin to scale rem values.
# This lets us use rem's in our css instead of pixels while remaining webgui-compatible without additional hacks.
Expand Down
2 changes: 1 addition & 1 deletion web/_data/serverState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ switch (state) {
// const connectPluginInstalled = 'dynamix.unraid.net.staging.plg';
const connectPluginInstalled = 'dynamix.unraid.net.staging.plg';

const osVersion = '7.0.0-beta.2.10';
const osVersion = '7.0.0';
const osVersionBranch = 'stable';
// const parsedRegExp = regExp ? dayjs(regExp).format('YYYY-MM-DD') : undefined;

Expand Down
4 changes: 2 additions & 2 deletions web/components/CallbackHandler.ce.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useCallbackStore } from '~/store/callbackActions';
import { useCallbackActionsStore } from '~/store/callbackActions';

const callbackStore = useCallbackStore();
const callbackStore = useCallbackActionsStore();

onBeforeMount(() => {
callbackStore.watcher();
Expand Down
6 changes: 3 additions & 3 deletions web/components/UserProfile.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { devConfig } from '~/helpers/env';

import type { Server } from '~/types/server';

import { useCallbackActionsStore, useCallbackStore } from '~/store/callbackActions';
import { useCallbackActionsStore } from '~/store/callbackActions';
import { useServerStore } from '~/store/server';
import { useThemeStore } from '~/store/theme';

Expand All @@ -18,10 +18,10 @@ const props = defineProps<Props>();

const { t } = useI18n();

const callbackStore = useCallbackStore();
const callbackStore = useCallbackActionsStore();
const serverStore = useServerStore();

const { callbackData } = storeToRefs(useCallbackActionsStore());
const { callbackData } = storeToRefs(callbackStore);
const { name, description, guid, keyfile, lanIp, connectPluginInstalled } = storeToRefs(serverStore);
const { bannerGradient, theme } = storeToRefs(useThemeStore());

Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@jsonforms/vue-vuetify": "^3.5.1",
"@nuxtjs/color-mode": "^3.5.2",
"@pinia/nuxt": "^0.10.0",
"@unraid/shared-callbacks": "^1.0.1",
"@unraid/ui": "link:../unraid-ui",
"@vue/apollo-composable": "^4.2.1",
"@vueuse/components": "^13.0.0",
Expand Down
2 changes: 1 addition & 1 deletion web/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BrandButton, BrandLogo, Toaster } from '@unraid/ui';
import { useDummyServerStore } from '~/_data/serverState';
import AES from 'crypto-js/aes';

import type { SendPayloads } from '~/store/callback';
import type { SendPayloads } from '@unraid/shared-callbacks';

import LogViewerCe from '~/components/Logs/LogViewer.ce.vue';
import SsoButtonCe from '~/components/SsoButton.ce.vue';
Expand Down
42 changes: 42 additions & 0 deletions web/pages/redirect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
const parseRedirectTarget = (target: string | null) => {
if (target && target !== '/') {
// parse target and ensure it is a bare path with no query parameters
console.log(target);
return '/';
}
return '/';
};
Comment on lines +2 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

The parseRedirectTarget function doesn't perform any actual validation

This function has a comment indicating it should parse and ensure the target is a bare path without query parameters, but it actually just logs the target and always returns '/'. This makes the conditional logic ineffective as the function will always return the home route regardless of input.

const parseRedirectTarget = (target: string | null) => {
  if (target && target !== '/') {
    // parse target and ensure it is a bare path with no query parameters
-    console.log(target);
-    return '/';
+    // Remove query parameters if present
+    const parsedUrl = new URL(target, window.location.origin);
+    return parsedUrl.pathname;
  }
  return '/';
};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const parseRedirectTarget = (target: string | null) => {
if (target && target !== '/') {
// parse target and ensure it is a bare path with no query parameters
console.log(target);
return '/';
}
return '/';
};
const parseRedirectTarget = (target: string | null) => {
if (target && target !== '/') {
// parse target and ensure it is a bare path with no query parameters
// Remove query parameters if present
const parsedUrl = new URL(target, window.location.origin);
return parsedUrl.pathname;
}
return '/';
};


const getRedirectUrl = () => {
const search = new URLSearchParams(window.location.search);
const targetRoute = parseRedirectTarget(search.get('target'));
if (search.has('data') && (search.size === 1 || search.size === 2)) {
return `${window.location.origin}${targetRoute}?data=${encodeURIComponent(search.get('data')!)}`;
}
return `${window.location.origin}${targetRoute}`;
};

onMounted(() => {
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it will immediately redirect without ever showing the text. What's the desired ux for this?

const textElement = document.getElementById('text');
if (textElement) {
textElement.style.display = 'block';
}
}, 750);

window.location.href = getRedirectUrl();
});
Comment on lines +20 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing import for onMounted

The onMounted function is used but there's no import statement for it.

<script setup lang="ts">
+import { onMounted } from 'vue';

const parseRedirectTarget = (target: string | null) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onMounted(() => {
setTimeout(() => {
const textElement = document.getElementById('text');
if (textElement) {
textElement.style.display = 'block';
}
}, 750);
window.location.href = getRedirectUrl();
});
<script setup lang="ts">
import { onMounted } from 'vue';
const parseRedirectTarget = (target: string | null) => {
// ... rest of the code
}
onMounted(() => {
setTimeout(() => {
const textElement = document.getElementById('text');
if (textElement) {
textElement.style.display = 'block';
}
}, 750);
window.location.href = getRedirectUrl();
});
</script>

</script>

<template>
<div>
<div
id="text"
style="text-align: center; margin-top: calc(100vh - 75%); display: none; font-family: sans-serif"
>
<h1>Redirecting...</h1>
<h2><a :href="getRedirectUrl()">Click here if you are not redirected automatically</a></h2>
</div>
</div>
</template>
6 changes: 3 additions & 3 deletions web/store/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { logErrorMessages } from '@vue/apollo-util';
import { defineStore, createPinia, setActivePinia } from 'pinia';

import { CONNECT_SIGN_IN, CONNECT_SIGN_OUT } from './account.fragment';
import { useCallbackStore } from '~/store/callbackActions';
import { useCallbackActionsStore } from '~/store/callbackActions';
import { useErrorsStore } from '~/store/errors';
import { useReplaceRenewStore } from '~/store/replaceRenew';
import { useServerStore } from '~/store/server';
import { useUnraidApiStore } from '~/store/unraidApi';
import { ACCOUNT_CALLBACK } from '~/helpers/urls';
import type { ExternalSignIn, ExternalSignOut } from '~/store/callback';
import type { ExternalSignIn, ExternalSignOut } from '@unraid/shared-callbacks';
/**
* @see https://stackoverflow.com/questions/73476371/using-pinia-with-vue-js-web-components
* @see https://github.com/vuejs/pinia/discussions/1085
Expand All @@ -23,7 +23,7 @@ export interface ConnectSignInMutationPayload {
}

export const useAccountStore = defineStore('account', () => {
const callbackStore = useCallbackStore();
const callbackStore = useCallbackActionsStore();
const errorsStore = useErrorsStore();
const replaceRenewStore = useReplaceRenewStore();
const serverStore = useServerStore();
Expand Down
230 changes: 0 additions & 230 deletions web/store/callback.ts

This file was deleted.

Loading
Loading