diff --git a/packages/devtools/client/components/AuthConfirmDialog.vue b/packages/devtools/client/components/AuthConfirmDialog.vue
index 4b2d2d52c..b433b8ee4 100644
--- a/packages/devtools/client/components/AuthConfirmDialog.vue
+++ b/packages/devtools/client/components/AuthConfirmDialog.vue
@@ -1,30 +1,17 @@
-
- This operation requires permissions for running command and access files from the browser.
-
- A request is sent to the server.
- Permissions required
-
-
- Please check your terminal for the instructions and then come back.
-
Permissions required
@@ -43,20 +43,25 @@ async function input() {
A request is sent to the server.
Please check your terminal for the instructions and then come back.
Or you can manually paste the token here:
- diff --git a/packages/devtools/client/composables/dev-auth.ts b/packages/devtools/client/composables/dev-auth.ts index 4a4c430c8..2b58f19cc 100644 --- a/packages/devtools/client/composables/dev-auth.ts +++ b/packages/devtools/client/composables/dev-auth.ts @@ -31,33 +31,8 @@ export async function ensureDevAuthToken() { if (isDevAuthed.value) return devAuthToken.value! - if (!devAuthToken.value) { - const info = new UAParser(navigator.userAgent).getResult() - const desc = [ - info.browser.name, - info.browser.version, - '|', - info.os.name, - info.os.version, - info.device.type, - ].filter(i => i).join(' ') - rpc.requestForAuth(desc) - - const result = await Promise.race([ - AuthComfirm.start(), - until(devAuthToken.value).toBeTruthy(), - ]) - - if (result === false) { - // @unocss-include - showNotification({ - message: 'Action canceled', - icon: 'carbon-close', - classes: 'text-orange', - }) - throw new Error('User canceled auth') - } - } + if (!devAuthToken.value) + await authConfirmAction() isDevAuthed.value = await rpc.verifyAuthToken(devAuthToken.value!) if (!isDevAuthed.value) { @@ -67,8 +42,37 @@ export async function ensureDevAuthToken() { icon: 'i-carbon-warning-alt', classes: 'text-red', }) + await authConfirmAction() throw new Error('Invalid auth token') } return devAuthToken.value! } + +async function authConfirmAction() { + const info = new UAParser(navigator.userAgent).getResult() + const desc = [ + info.browser.name, + info.browser.version, + '|', + info.os.name, + info.os.version, + info.device.type, + ].filter(i => i).join(' ') + rpc.requestForAuth(desc) + + const result = await Promise.race([ + AuthConfirm.start(), + until(devAuthToken.value).toBeTruthy(), + ]) + + if (result === false) { + // @unocss-include + showNotification({ + message: 'Action canceled', + icon: 'carbon-close', + classes: 'text-orange', + }) + throw new Error('User canceled auth') + } +} diff --git a/packages/devtools/client/composables/dialog.ts b/packages/devtools/client/composables/dialog.ts index c7a446aef..83a4d3c8c 100644 --- a/packages/devtools/client/composables/dialog.ts +++ b/packages/devtools/client/composables/dialog.ts @@ -2,7 +2,7 @@ import type { InstallModuleReturn, ModuleActionType, ModuleStaticInfo } from '.. export const ModuleDialog = createTemplatePromise