Fix login in Tauri v2 (#2493)

This commit is contained in:
Vítor Vasconcellos 2024-05-16 11:23:34 -03:00 committed by GitHub
parent e7ced995b9
commit f847b76154
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 13 deletions

View file

@ -4,22 +4,27 @@
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"path:default",
"event:default",
"window:default",
"app:default",
"event:default",
"image:default",
"resources:default",
"menu:default",
"path:default",
"resources:default",
"window:default",
"tray:default",
"webview:default",
"webview:allow-internal-toggle-devtools",
"os:allow-os-type",
"window:allow-start-dragging",
"window:default",
"shell:allow-open",
"dialog:allow-open",
"dialog:allow-save",
"dialog:allow-confirm",
"os:allow-os-type",
"window:allow-close",
"window:allow-create",
"window:allow-maximize",
"window:allow-minimize",
"window:allow-toggle-maximize",
"dialog:allow-confirm"
"window:allow-start-dragging",
"webview:allow-internal-toggle-devtools"
]
}

View file

@ -9,7 +9,6 @@ import { OperatingSystem, Platform } from '@sd/interface';
import { commands, events } from './commands';
import { env } from './env';
import { createUpdater } from './updater';
const customUriAuthToken = (window as any).__SD_CUSTOM_SERVER_AUTH_TOKEN__ as string | undefined;
const customUriServerUrl = (window as any).__SD_CUSTOM_URI_SERVER__ as string[] | undefined;
@ -86,7 +85,7 @@ export const platform = {
userHomeDir: homeDir,
auth: {
start(url) {
open(url);
return shellOpen(url);
}
},
...commands,

View file

@ -51,9 +51,17 @@ export function login(config: ProviderConfig) {
if (data === 'Complete') {
config.finish?.(authCleanup);
loginCallbacks.forEach((cb) => cb('success'));
} else if ('Error' in data) onError(data.Error);
else {
authCleanup = config.start(data.Start.verification_url_complete);
} else if ('Error' in data) {
onError(data.Error);
} else {
Promise.resolve()
.then(() => config.start(data.Start.verification_url_complete))
.then(
(res) => {
authCleanup = res;
},
(e) => onError(e.message)
);
}
},
onError(e) {