Compare commits
1 Commits
master
...
work-issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a18b15b4cc |
@ -80,7 +80,7 @@ function PairingDialog({ onPair }: { onPair: (code: string) => Promise<void> })
|
||||
}
|
||||
|
||||
function AppContent() {
|
||||
const { isAuthenticated, loading, pair, logout } = useAuth();
|
||||
const { isAuthenticated, requiresPairing, loading, pair, logout } = useAuth();
|
||||
const [locale, setLocaleState] = useState('tr');
|
||||
|
||||
const setAppLocale = (newLocale: string) => {
|
||||
@ -105,7 +105,7 @@ function AppContent() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
if (!isAuthenticated && requiresPairing) {
|
||||
return <PairingDialog onPair={pair} />;
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@ export interface AuthState {
|
||||
token: string | null;
|
||||
/** Whether the user is currently authenticated. */
|
||||
isAuthenticated: boolean;
|
||||
/** Whether the server requires pairing. Defaults to true (safe fallback). */
|
||||
requiresPairing: boolean;
|
||||
/** True while the initial auth check is in progress. */
|
||||
loading: boolean;
|
||||
/** Pair with the agent using a pairing code. Stores the token on success. */
|
||||
@ -45,6 +47,7 @@ export interface AuthProviderProps {
|
||||
export function AuthProvider({ children }: AuthProviderProps) {
|
||||
const [token, setTokenState] = useState<string | null>(readToken);
|
||||
const [authenticated, setAuthenticated] = useState<boolean>(checkAuth);
|
||||
const [requiresPairing, setRequiresPairing] = useState<boolean>(true);
|
||||
const [loading, setLoading] = useState<boolean>(!checkAuth());
|
||||
|
||||
// On mount: check if server requires pairing at all
|
||||
@ -55,6 +58,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
||||
.then((health) => {
|
||||
if (cancelled) return;
|
||||
if (!health.require_pairing) {
|
||||
setRequiresPairing(false);
|
||||
setAuthenticated(true);
|
||||
}
|
||||
})
|
||||
@ -98,6 +102,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
||||
const value: AuthState = {
|
||||
token,
|
||||
isAuthenticated: authenticated,
|
||||
requiresPairing,
|
||||
loading,
|
||||
pair,
|
||||
logout,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user