feat: remove sessions after reboot
This commit is contained in:
@@ -57,6 +57,22 @@ export function Auth({
|
||||
...props
|
||||
}: AuthProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Detect if we're running in Electron's WebView/iframe
|
||||
const isInElectronWebView = () => {
|
||||
try {
|
||||
// Check if we're in an iframe AND the parent is Electron
|
||||
if (window.self !== window.top) {
|
||||
// We're in an iframe, likely Electron's ElectronLoginForm
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// Cross-origin iframe, can't access parent
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const [tab, setTab] = useState<"login" | "signup" | "external" | "reset">(
|
||||
"login",
|
||||
);
|
||||
@@ -92,12 +108,22 @@ export function Auth({
|
||||
}, [loggedIn]);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip when in Electron WebView iframe
|
||||
if (isInElectronWebView()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getRegistrationAllowed().then((res) => {
|
||||
setRegistrationAllowed(res.allowed);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip when in Electron WebView iframe
|
||||
if (isInElectronWebView()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPasswordLoginAllowed()
|
||||
.then((res) => {
|
||||
setPasswordLoginAllowed(res.allowed);
|
||||
@@ -110,6 +136,11 @@ export function Auth({
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip when in Electron WebView iframe
|
||||
if (isInElectronWebView()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getOIDCConfig()
|
||||
.then((response) => {
|
||||
if (response) {
|
||||
@@ -128,6 +159,14 @@ export function Auth({
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip database health check when in Electron WebView iframe
|
||||
// The parent Electron window will handle authentication
|
||||
if (isInElectronWebView()) {
|
||||
setDbHealthChecking(false);
|
||||
setDbConnectionFailed(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setDbHealthChecking(true);
|
||||
getSetupRequired()
|
||||
.then((res) => {
|
||||
@@ -691,21 +730,6 @@ export function Auth({
|
||||
);
|
||||
}
|
||||
|
||||
// Detect if we're running in Electron's WebView/iframe
|
||||
const isInElectronWebView = () => {
|
||||
try {
|
||||
// Check if we're in an iframe AND the parent is Electron
|
||||
if (window.self !== window.top) {
|
||||
// We're in an iframe, likely Electron's ElectronLoginForm
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// Cross-origin iframe, can't access parent
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`w-[420px] max-w-full p-6 flex flex-col bg-dark-bg border-2 border-dark-border rounded-md ${className || ""}`}
|
||||
|
||||
@@ -200,7 +200,20 @@ function createApiInstance(
|
||||
}
|
||||
|
||||
if (typeof window !== "undefined" && (window as any).ReactNativeWebView) {
|
||||
config.headers["User-Agent"] = "Termix-Mobile";
|
||||
// Try to detect platform from navigator
|
||||
let platform = "Unknown";
|
||||
if (typeof navigator !== "undefined" && navigator.userAgent) {
|
||||
if (navigator.userAgent.includes("Android")) {
|
||||
platform = "Android";
|
||||
} else if (
|
||||
navigator.userAgent.includes("iPhone") ||
|
||||
navigator.userAgent.includes("iPad") ||
|
||||
navigator.userAgent.includes("iOS")
|
||||
) {
|
||||
platform = "iOS";
|
||||
}
|
||||
}
|
||||
config.headers["User-Agent"] = `Termix-Mobile/${platform}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
Reference in New Issue
Block a user