Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions new-ui/src/shared/components/LocationCard/context/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { api } from '../../../rust-api/api';
import type { InstanceInfo, LocationInfo } from '../../../rust-api/types';
import { ConnectionType, MfaMethod, type MfaMethodValue } from '../../../rust-api/types';
import { useAppStore } from '../../../store/useAppStore';
import { isPresent } from '../../../utils/isPresent';
import { LocationCardViews, type LocationCardViewsValue } from './types';

interface LocationCardContextValue {
Expand Down Expand Up @@ -50,7 +51,8 @@ export const LocationCardProvider = ({
children,
}: LocationCardProviderProps) => {
const conTypeSetOnce = useRef(false);
const { setConnectionMethod } = useAppData();
const mfaStarted = useRef(false);
const { connectionMfaMethod, setConnectionMethod } = useAppData();
const [autoConnectOpenid, setAutoConnectOpenid] = useState(false);
const [previousView, setPreviousView] = useState<LocationCardViewsValue | null>(null);
const [postureError, setPostureError] = useState<string | null>(null);
Expand Down Expand Up @@ -81,6 +83,7 @@ export const LocationCardProvider = ({
);

const startMfa = useCallback(async () => {
mfaStarted.current = true;
const appConfig = await api.getAppConfig();
setAutoConnectOpenid(appConfig.auto_start_openid_mfa);
switch (mfaMethod) {
Expand Down Expand Up @@ -120,11 +123,15 @@ export const LocationCardProvider = ({
location.connection_type !== ConnectionType.Tunnel &&
!conTypeSetOnce.current
) {
conTypeSetOnce.current = true;
setConnectionMethod(location.id, location.connection_type, mfaMethod);
const key = `${location.connection_type.toLowerCase()}-${location.id}`;
if (mfaStarted.current || !isPresent(connectionMfaMethod[key])) {
conTypeSetOnce.current = true;
setConnectionMethod(location.id, location.connection_type, mfaMethod);
}
}
if (!location.active) {
conTypeSetOnce.current = false;
mfaStarted.current = false;
}
}, [location.active]);

Expand Down
38 changes: 19 additions & 19 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading