fix: remove 10 unused variables in HomepageAuth.tsx
Removed unused variables: - getCookie import - dbError prop - visibility state and toggleVisibility - error state variable - result variable in handleInitiatePasswordReset - token URL parameter - err parameters in catch blocks - retryDatabaseConnection function - Multiple setError(null) calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
|||||||
completePasswordReset,
|
completePasswordReset,
|
||||||
getOIDCAuthorizeUrl,
|
getOIDCAuthorizeUrl,
|
||||||
verifyTOTPLogin,
|
verifyTOTPLogin,
|
||||||
getCookie,
|
|
||||||
getServerConfig,
|
getServerConfig,
|
||||||
isElectron,
|
isElectron,
|
||||||
logoutUser,
|
logoutUser,
|
||||||
@@ -33,7 +32,6 @@ interface HomepageAuthProps extends React.ComponentProps<"div"> {
|
|||||||
setUserId: (userId: string | null) => void;
|
setUserId: (userId: string | null) => void;
|
||||||
loggedIn: boolean;
|
loggedIn: boolean;
|
||||||
authLoading: boolean;
|
authLoading: boolean;
|
||||||
dbError: string | null;
|
|
||||||
setDbError: (error: string | null) => void;
|
setDbError: (error: string | null) => void;
|
||||||
onAuthSuccess: (authData: {
|
onAuthSuccess: (authData: {
|
||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
@@ -50,7 +48,6 @@ export function HomepageAuth({
|
|||||||
setUserId,
|
setUserId,
|
||||||
loggedIn,
|
loggedIn,
|
||||||
authLoading,
|
authLoading,
|
||||||
dbError,
|
|
||||||
setDbError,
|
setDbError,
|
||||||
onAuthSuccess,
|
onAuthSuccess,
|
||||||
...props
|
...props
|
||||||
@@ -64,17 +61,6 @@ export function HomepageAuth({
|
|||||||
const [signupConfirmPassword, setSignupConfirmPassword] = useState("");
|
const [signupConfirmPassword, setSignupConfirmPassword] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [oidcLoading, setOidcLoading] = useState(false);
|
const [oidcLoading, setOidcLoading] = useState(false);
|
||||||
const [visibility, setVisibility] = useState({
|
|
||||||
password: false,
|
|
||||||
signupConfirm: false,
|
|
||||||
resetNew: false,
|
|
||||||
resetConfirm: false,
|
|
||||||
});
|
|
||||||
const toggleVisibility = (field: keyof typeof visibility) => {
|
|
||||||
setVisibility((prev) => ({ ...prev, [field]: !prev[field] }));
|
|
||||||
};
|
|
||||||
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const [internalLoggedIn, setInternalLoggedIn] = useState(false);
|
const [internalLoggedIn, setInternalLoggedIn] = useState(false);
|
||||||
const [firstUser, setFirstUser] = useState(false);
|
const [firstUser, setFirstUser] = useState(false);
|
||||||
const [firstUserToastShown, setFirstUserToastShown] = useState(false);
|
const [firstUserToastShown, setFirstUserToastShown] = useState(false);
|
||||||
@@ -169,7 +155,6 @@ export function HomepageAuth({
|
|||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setError(null);
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
if (!localUsername.trim()) {
|
if (!localUsername.trim()) {
|
||||||
@@ -252,10 +237,9 @@ export function HomepageAuth({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleInitiatePasswordReset() {
|
async function handleInitiatePasswordReset() {
|
||||||
setError(null);
|
|
||||||
setResetLoading(true);
|
setResetLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await initiatePasswordReset(localUsername);
|
await initiatePasswordReset(localUsername);
|
||||||
setResetStep("verify");
|
setResetStep("verify");
|
||||||
toast.success(t("messages.resetCodeSent"));
|
toast.success(t("messages.resetCodeSent"));
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -270,7 +254,6 @@ export function HomepageAuth({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleVerifyResetCode() {
|
async function handleVerifyResetCode() {
|
||||||
setError(null);
|
|
||||||
setResetLoading(true);
|
setResetLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await verifyPasswordResetCode(localUsername, resetCode);
|
const response = await verifyPasswordResetCode(localUsername, resetCode);
|
||||||
@@ -285,7 +268,6 @@ export function HomepageAuth({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleCompletePasswordReset() {
|
async function handleCompletePasswordReset() {
|
||||||
setError(null);
|
|
||||||
setResetLoading(true);
|
setResetLoading(true);
|
||||||
|
|
||||||
if (newPassword !== confirmPassword) {
|
if (newPassword !== confirmPassword) {
|
||||||
@@ -308,7 +290,6 @@ export function HomepageAuth({
|
|||||||
setNewPassword("");
|
setNewPassword("");
|
||||||
setConfirmPassword("");
|
setConfirmPassword("");
|
||||||
setTempToken("");
|
setTempToken("");
|
||||||
setError(null);
|
|
||||||
|
|
||||||
setResetSuccess(true);
|
setResetSuccess(true);
|
||||||
toast.success(t("messages.passwordResetSuccess"));
|
toast.success(t("messages.passwordResetSuccess"));
|
||||||
@@ -330,7 +311,6 @@ export function HomepageAuth({
|
|||||||
setNewPassword("");
|
setNewPassword("");
|
||||||
setConfirmPassword("");
|
setConfirmPassword("");
|
||||||
setTempToken("");
|
setTempToken("");
|
||||||
setError(null);
|
|
||||||
setResetSuccess(false);
|
setResetSuccess(false);
|
||||||
setSignupConfirmPassword("");
|
setSignupConfirmPassword("");
|
||||||
}
|
}
|
||||||
@@ -338,7 +318,6 @@ export function HomepageAuth({
|
|||||||
function clearFormFields() {
|
function clearFormFields() {
|
||||||
setPassword("");
|
setPassword("");
|
||||||
setSignupConfirmPassword("");
|
setSignupConfirmPassword("");
|
||||||
setError(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleTOTPVerification() {
|
async function handleTOTPVerification() {
|
||||||
@@ -347,7 +326,6 @@ export function HomepageAuth({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setError(null);
|
|
||||||
setTotpLoading(true);
|
setTotpLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -403,7 +381,6 @@ export function HomepageAuth({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleOIDCLogin() {
|
async function handleOIDCLogin() {
|
||||||
setError(null);
|
|
||||||
setOidcLoading(true);
|
setOidcLoading(true);
|
||||||
try {
|
try {
|
||||||
const authResponse = await getOIDCAuthorizeUrl();
|
const authResponse = await getOIDCAuthorizeUrl();
|
||||||
@@ -427,7 +404,6 @@ export function HomepageAuth({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const success = urlParams.get("success");
|
const success = urlParams.get("success");
|
||||||
const token = urlParams.get("token");
|
|
||||||
const error = urlParams.get("error");
|
const error = urlParams.get("error");
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -439,7 +415,6 @@ export function HomepageAuth({
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
setOidcLoading(true);
|
setOidcLoading(true);
|
||||||
setError(null);
|
|
||||||
|
|
||||||
getUserInfo()
|
getUserInfo()
|
||||||
.then((meRes) => {
|
.then((meRes) => {
|
||||||
@@ -461,7 +436,7 @@ export function HomepageAuth({
|
|||||||
window.location.pathname,
|
window.location.pathname,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(() => {
|
||||||
setInternalLoggedIn(false);
|
setInternalLoggedIn(false);
|
||||||
setLoggedIn(false);
|
setLoggedIn(false);
|
||||||
setIsAdmin(false);
|
setIsAdmin(false);
|
||||||
@@ -514,26 +489,6 @@ export function HomepageAuth({
|
|||||||
}
|
}
|
||||||
}, [dbConnectionFailed, t]);
|
}, [dbConnectionFailed, t]);
|
||||||
|
|
||||||
const retryDatabaseConnection = async () => {
|
|
||||||
setDbHealthChecking(true);
|
|
||||||
setDbConnectionFailed(false);
|
|
||||||
try {
|
|
||||||
const res = await getSetupRequired();
|
|
||||||
if (res.setup_required) {
|
|
||||||
setFirstUser(true);
|
|
||||||
setTab("signup");
|
|
||||||
} else {
|
|
||||||
setFirstUser(false);
|
|
||||||
}
|
|
||||||
setDbError(null);
|
|
||||||
toast.success(t("messages.databaseConnected"));
|
|
||||||
} catch (error) {
|
|
||||||
setDbConnectionFailed(true);
|
|
||||||
} finally {
|
|
||||||
setDbHealthChecking(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkServerConfig = async () => {
|
const checkServerConfig = async () => {
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
@@ -541,7 +496,7 @@ export function HomepageAuth({
|
|||||||
const config = await getServerConfig();
|
const config = await getServerConfig();
|
||||||
setCurrentServerUrl(config?.serverUrl || "");
|
setCurrentServerUrl(config?.serverUrl || "");
|
||||||
setShowServerConfig(!config || !config.serverUrl);
|
setShowServerConfig(!config || !config.serverUrl);
|
||||||
} catch (error) {
|
} catch {
|
||||||
setShowServerConfig(true);
|
setShowServerConfig(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -712,7 +667,6 @@ export function HomepageAuth({
|
|||||||
setTotpRequired(false);
|
setTotpRequired(false);
|
||||||
setTotpCode("");
|
setTotpCode("");
|
||||||
setTotpTempToken("");
|
setTotpTempToken("");
|
||||||
setError(null);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("common.cancel")}
|
{t("common.cancel")}
|
||||||
|
|||||||
Reference in New Issue
Block a user