Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: errorCallbackURL redirect loop, empty <p>, integration test

tiran13381c5d6a8255b
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index 134226344..1c3b5bd4a 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -25,6 +25,7 @@ const signInSearchSchema = z.object({
invitationId: z.string().optional(),
email: z.string().optional(),
redirect: z.string().optional(),
+ error: z.string().optional(),
});
export const Route = createFileRoute("/auth/sign-in")({
@@ -185,16 +186,23 @@ function SignIn() {
}
};
+ useEffect(() => {
+ if (search.error) {
+ setAutoLoginFailed(true);
+ }
+ }, [search.error]);
+
useEffect(() => {
if (
config?.customOAuthAutoLogin &&
config?.hasCustomOAuth &&
- !autoLoginTriggered.current
+ !autoLoginTriggered.current &&
+ !search.error
) {
autoLoginTriggered.current = true;
handleCustomOAuth();
}
- }, [config, handleCustomOAuth]);
+ }, [config, handleCustomOAuth, search.error]);
// Treat "no users yet" as still loading so the skeleton stays visible
// while the useEffect above redirects to /auth/sign-up. Otherwise the
@@ -230,6 +238,21 @@ function SignIn() {
}
>
<div className="mt-6">
+ {search.error && (
+ <Alert variant="error" className="mb-4">
+ <AlertDescription>
+ {(() => {
+ const errorKey = search.error
+ .replace(/[._]+/g, "_")
+ .toLowerCase();
+ const translationKey = `auth:signIn.errors.${errorKey}`;
+ const translated = t(translationKey, { defaultValue: "" });
+ return translated || search.error.replace(/_/g, " ");
+ })()}
+ </AlertDescription>
+ </Alert>
+ )}
+
{invitationId && (
<Alert className="mb-4">
<AlertDescription>
@@ -390,24 +413,21 @@ function SignIn() {
/>
))}
{config?.disableRegistration ||
- config?.disablePasswordRegistration ||
- config?.disableLoginForm ? (
+ config?.disablePasswordRegistration ? (
<div className="text-center pt-4">
<p className="text-sm text-muted-foreground">
{config?.disableRegistration
? t("auth:signIn.registrationDisabled")
- : config?.disableLoginForm
- ? ""
- : t("auth:signIn.passwordRegistrationDisabled")}
+ : t("auth:signIn.passwordRegistrationDisabled")}
</p>
</div>
- ) : (
+ ) : !config?.disableLoginForm ? (
<AuthToggle
message={t("auth:signIn.toggleMessage")}
linkText={t("auth:signIn.toggleLink")}
linkTo="/auth/sign-up"
/>
- )}
+ ) : null}
</div>
</AuthLayout>
</>
diff --git a/i18n/en-US.json b/i18n/en-US.json
index 4493823ee..6bb8708ae 100644
--- a/i18n/en-US.json
+++ b/i18n/en-US.json
@@ -150,7 +150,11 @@
"oidcError": "Failed to sign in with OIDC",
"googleError": "Failed to sign in with Google",
"githubError": "Failed to sign in with GitHub",
- "discordError": "Failed to sign in with Discord"
+ "discordError": "Failed to sign in with Discord",
+ "errors": {
+ "oauth_code_verification_failed": "OAuth verification failed. Please try again.",
+ "registration_is_currently_disabled_you_need_a_valid_invitation_to_create_an_account_": "Registration is currently disabled. You need a valid invitation to create an account."
+ }
},
"providers": {
"google": "Google",
diff --git a/tests/api-integration/config.test.ts b/tests/api-integration/config.test.ts
index bf9b53a27..e50a94090 100644
--- a/tests/api-integration/config.test.ts
+++ b/tests/api-integration/config.test.ts
@@ -13,8 +13,8 @@ describe("API integration: config", () => {
expect(payload).toMatchObject({
disableRegistration: false,
disablePasswordRegistration: false,
- disableLoginForm: expect.any(Boolean),
- customOAuthAutoLogin: expect.any(Boolean),
+ disableLoginForm: false,
+ customOAuthAutoLogin: false,
isDemoMode: false,
hasGuestAccess: true,
});
diff --git a/tests/api-integration/setup.ts b/tests/api-integration/setup.ts
index 55c94adf2..71d1cc8e2 100644
--- a/tests/api-integration/setup.ts
+++ b/tests/api-integration/setup.ts
@@ -3,6 +3,12 @@ import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, vi } from "vitest";
+// Prevent dotenv-mono from loading the local .env file during tests.
+// All env vars are set explicitly below — the .env file must be ignored.
+vi.mock("dotenv-mono", () => ({
+ config: () => {},
+}));
+
function stripEnvValueQuotes(value: string) {
const trimmed = value.trim();
if (
@@ -66,6 +72,7 @@ process.env.KANEO_CLIENT_URL = "http://localhost:5173";
process.env.DISABLE_GUEST_ACCESS = "false";
process.env.DISABLE_REGISTRATION = "false";
process.env.DISABLE_PASSWORD_REGISTRATION = "false";
+process.env.DISABLE_LOGIN_FORM = "";
process.env.DEMO_MODE = "false";
process.env.SMTP_HOST = "";
process.env.SMTP_PORT = "";
@@ -88,6 +95,7 @@ process.env.CUSTOM_OAUTH_USER_INFO_URL = "";
process.env.CUSTOM_OAUTH_SCOPES = "";
process.env.CUSTOM_OAUTH_RESPONSE_TYPE = "";
process.env.CUSTOM_OAUTH_DISCOVERY_URL = "";
+process.env.CUSTOM_OAUTH_AUTO_LOGIN = "";
process.env.DEVICE_AUTH_CLIENT_IDS = "kaneo-cli";
afterEach(() => {