fix: oidc, global default, and remember me issues

This commit is contained in:
LukeGus
2026-03-10 23:32:43 -05:00
parent ea2e59abd8
commit a255a08903
10 changed files with 186 additions and 122 deletions
@@ -88,8 +88,12 @@ export function GeneralSettingsTab({
metricsInterval: newMetrics,
});
toast.success(t("admin.globalSettingsSaved"));
} catch {
toast.error(t("admin.failedToSaveGlobalSettings"));
} catch (error) {
const errorMessage =
error instanceof Error
? error.message
: t("admin.failedToSaveGlobalSettings");
toast.error(errorMessage);
} finally {
setMonitoringLoading(false);
}
+16 -1
View File
@@ -104,7 +104,14 @@ export function Auth({
const [localUsername, setLocalUsername] = useState("");
const [password, setPassword] = useState("");
const [signupConfirmPassword, setSignupConfirmPassword] = useState("");
const [rememberMe, setRememberMe] = useState(false);
const [rememberMe, setRememberMe] = useState(() => {
try {
const saved = localStorage.getItem("rememberMe");
return saved === "true";
} catch {
return false;
}
});
const [loading, setLoading] = useState(false);
const [oidcLoading, setOidcLoading] = useState(false);
const [internalLoggedIn, setInternalLoggedIn] = useState(false);
@@ -175,6 +182,14 @@ export function Auth({
}
}, [totpRequired]);
useEffect(() => {
try {
localStorage.setItem("rememberMe", rememberMe.toString());
} catch {
// expected - localStorage might not be available
}
}, [rememberMe]);
useEffect(() => {
getRegistrationAllowed().then((res) => {
setRegistrationAllowed(res.allowed);
+38 -3
View File
@@ -3,6 +3,7 @@ import { cn } from "@/lib/utils.ts";
import { Button } from "@/components/ui/button.tsx";
import { Input } from "@/components/ui/input.tsx";
import { Label } from "@/components/ui/label.tsx";
import { Checkbox } from "@/components/ui/checkbox.tsx";
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert.tsx";
import { useTranslation } from "react-i18next";
import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx";
@@ -93,6 +94,14 @@ export function Auth({
const [localUsername, setLocalUsername] = useState("");
const [password, setPassword] = useState("");
const [signupConfirmPassword, setSignupConfirmPassword] = useState("");
const [rememberMe, setRememberMe] = useState(() => {
try {
const saved = localStorage.getItem("rememberMe");
return saved === "true";
} catch {
return false;
}
});
const [loading, setLoading] = useState(false);
const [oidcLoading, setOidcLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -130,6 +139,14 @@ export function Auth({
}
}, [totpRequired]);
useEffect(() => {
try {
localStorage.setItem("rememberMe", rememberMe.toString());
} catch {
// expected - localStorage might not be available
}
}, [rememberMe]);
useEffect(() => {
getRegistrationAllowed().then((res) => {
setRegistrationAllowed(res.allowed);
@@ -218,7 +235,7 @@ export function Auth({
try {
let res;
if (tab === "login") {
res = await loginUser(localUsername, password);
res = await loginUser(localUsername, password, rememberMe);
} else {
if (password !== signupConfirmPassword) {
toast.error(t("errors.passwordMismatch"));
@@ -232,7 +249,7 @@ export function Auth({
}
await registerUser(localUsername, password);
res = await loginUser(localUsername, password);
res = await loginUser(localUsername, password, rememberMe);
}
if (res.requires_totp) {
@@ -441,7 +458,7 @@ export function Auth({
setTotpLoading(true);
try {
const res = await verifyTOTPLogin(totpTempToken, totpCode);
const res = await verifyTOTPLogin(totpTempToken, totpCode, rememberMe);
if (!res || !res.success) {
throw new Error(t("errors.loginFailed"));
@@ -1108,6 +1125,24 @@ export function Auth({
disabled={loading || internalLoggedIn}
/>
</div>
{tab === "login" && (
<div className="flex items-center gap-2">
<Checkbox
id="rememberMe"
checked={rememberMe}
onCheckedChange={(checked) =>
setRememberMe(checked === true)
}
disabled={loading || internalLoggedIn}
/>
<Label
htmlFor="rememberMe"
className="text-sm font-normal cursor-pointer"
>
{t("auth.rememberMe")}
</Label>
</div>
)}
{tab === "signup" && (
<div className="flex flex-col gap-2">
<Label htmlFor="signup-confirm-password">