mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
Change to use dpdm for circular import scanning (#5788)
Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
co-authored by
Anthony Stirling
parent
1b3bfaec20
commit
eab84a13d0
@@ -0,0 +1,27 @@
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
const TOKEN_KEY = 'stirling_jwt';
|
||||
|
||||
/**
|
||||
* Read auth token from any available source (Tauri store or localStorage).
|
||||
* Kept separate to avoid circular dependencies between auth and backend services.
|
||||
*/
|
||||
export async function getAuthTokenFromAnySource(): Promise<string | null> {
|
||||
// Try Tauri store first
|
||||
try {
|
||||
const token = await invoke<string | null>('get_auth_token');
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Desktop AuthTokenStore] Failed to read from Tauri store:', error);
|
||||
}
|
||||
|
||||
// Fallback to localStorage
|
||||
try {
|
||||
return localStorage.getItem(TOKEN_KEY);
|
||||
} catch (error) {
|
||||
console.error('[Desktop AuthTokenStore] Failed to read from localStorage:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { fetch } from '@tauri-apps/plugin-http';
|
||||
import { connectionModeService } from '@app/services/connectionModeService';
|
||||
import { getAuthTokenFromAnySource } from '@app/services/authTokenStore';
|
||||
|
||||
export type BackendStatus = 'stopped' | 'starting' | 'healthy' | 'unhealthy';
|
||||
|
||||
@@ -122,8 +123,7 @@ export class TauriBackendService {
|
||||
*/
|
||||
private async getAuthToken(): Promise<string | null> {
|
||||
try {
|
||||
const { authService } = await import('./authService');
|
||||
return await authService.getAuthToken();
|
||||
return await getAuthTokenFromAnySource();
|
||||
} catch (error) {
|
||||
console.debug('[TauriBackendService] Failed to get auth token:', error);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user