feat(esi): improve ESI SSO login flow and system name resolution
This commit introduces several improvements to the ESI (EVE Server Interface) Single Sign-On (SSO) flow and system name resolution: **ESI SSO Login Flow:** - **Asynchronous Callback Server:** The `StartCallbackServer` function is now deprecated in favor of `StartCallbackServerAsync`. This allows the callback server to run in the background without blocking the main application thread, improving responsiveness. - **Improved Login Status Polling:** After initiating the ESI login, the frontend now polls the `ESILoggedIn` status for a short period. This ensures that the UI reflects the login status more accurately and promptly after the user completes the authentication flow in their browser. - **Error Handling:** Added more specific error messages for failed token exchanges and invalid SSO responses. **System Name Resolution:** - **Multi-stage Resolution:** The `ResolveSystemIDByName` function now employs a more robust, multi-stage approach to find system IDs: 1. It first attempts to use the `universe/ids` endpoint for direct name-to-ID mapping, which is generally more accurate. 2. If that fails, it falls back to a `strict` search via the `search` endpoint. 3. As a final fallback, it performs a non-strict search and then resolves the names of the returned IDs to find an exact case-insensitive match. If no exact match is found, it returns the first result. - **Logging:** Added more detailed logging for each stage of the system name resolution process, aiding in debugging. - **ESI API Headers:** Ensured that necessary headers like `Accept` and `X-User-Agent` are correctly set for ESI API requests. **Frontend Changes:** - **Import `ESILoggedIn`:** The `ESILoggedIn` function is now imported into the `Header.tsx` component. - **Updated Toast Message:** The toast message for setting a destination now includes the system name for better context in case of errors.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
} from '@/components/ui/breadcrumb';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { StartESILogin, ESILoginStatus } from 'wailsjs/go/main/App';
|
||||
import { StartESILogin, ESILoginStatus, ESILoggedIn } from 'wailsjs/go/main/App';
|
||||
|
||||
interface HeaderProps {
|
||||
title: string;
|
||||
@@ -32,7 +32,17 @@ export const Header = ({ title, breadcrumbs = [] }: HeaderProps) => {
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Complete login in your browser. Reopen menu to refresh status.' });
|
||||
toast({ title: 'EVE Login', description: 'Complete login in your browser.' });
|
||||
// Poll a few times to update status after redirect callback
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const ok = await ESILoggedIn();
|
||||
if (ok) {
|
||||
const s = await ESILoginStatus();
|
||||
setStatus(s);
|
||||
break;
|
||||
}
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
}
|
||||
} catch (e: any) {
|
||||
toast({ title: 'Login failed', description: String(e), variant: 'destructive' });
|
||||
}
|
||||
|
Reference in New Issue
Block a user