Merge branch 'main' into default-redirect

This commit is contained in:
Max Peintner
2024-11-14 09:11:17 +01:00
committed by GitHub
31 changed files with 1305 additions and 1514 deletions

View File

@@ -34,52 +34,36 @@ jobs:
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1.45.0
- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
- name: Setup Node.js 20.x
uses: actions/setup-node@v4.0.2
with:
node-version: 20.x
- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: CYPRESS_INSTALL_BINARY=0 pnpm install
- run: echo "CYPRESS_VERSION=$(pnpm list -r | grep cypress | cut -d ' ' -f 2)" >> $GITHUB_ENV
if: ${{ matrix.command == 'test:integration' }}
cache: 'pnpm'
- uses: actions/cache@v4.0.2
name: Setup Cypress binary cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-binary-${{ env.CYPRESS_VERSION }}
key: ${{ runner.os }}-cypress-binary-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-cypress-binary-
if: ${{ matrix.command == 'test:integration' }}
# The Cypress binary cache needs to be updated together with the pnpm dependencies cache.
# That's why we don't conditionally cache it using if: ${{ matrix.command == 'test:integration' }}
- name: Install Cypress Browsers
run: pnpm install
if: ${{ matrix.command == 'test:integration' }}
- name: Install Dependencies
run: pnpm install --frozen-lockfile
# We can cache the Playwright binary independently from the pnpm cache, because we install it separately.
# After pnpm install --frozen-lockfile, we can get the version so we only have to download the binary once per version.
- run: echo "PLAYWRIGHT_VERSION=$(npx playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV
if: ${{ matrix.command == 'test:acceptance' }}
- uses: actions/cache@v4.0.2
name: Setup Playwright binary cache
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-binary-${{ env.PLAYWRIGHT_VERSION }}
@@ -89,7 +73,7 @@ jobs:
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
if: ${{ matrix.command == 'test:acceptance' }}
if: ${{ matrix.command == 'test:acceptance' && steps.playwright-cache.outputs.cache-hit != 'true' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -99,7 +83,7 @@ jobs:
run: ZITADEL_DEV_UID=root pnpm run-zitadel
if: ${{ matrix.command == 'test:acceptance' }}
- name: Install Playwright Browsers
- name: Create Production Build
run: pnpm build
if: ${{ matrix.command == 'test:acceptance' }}

View File

@@ -173,6 +173,7 @@
"error": {
"unknownContext": "Der Kontext des Benutzers konnte nicht ermittelt werden. Stellen Sie sicher, dass Sie zuerst den Benutzernamen eingeben oder einen loginName als Suchparameter angeben.",
"sessionExpired": "Ihre aktuelle Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.",
"failedLoading": "Daten konnten nicht geladen werden. Bitte versuchen Sie es erneut."
"failedLoading": "Daten konnten nicht geladen werden. Bitte versuchen Sie es erneut.",
"tryagain": "Erneut versuchen"
}
}

View File

@@ -173,6 +173,7 @@
"error": {
"unknownContext": "Could not get the context of the user. Make sure to enter the username first or provide a loginName as searchParam.",
"sessionExpired": "Your current session has expired. Please login again.",
"failedLoading": "Failed to load data. Please try again."
"failedLoading": "Failed to load data. Please try again.",
"tryagain": "Try Again"
}
}

View File

@@ -173,6 +173,7 @@
"error": {
"unknownContext": "No se pudo obtener el contexto del usuario. Asegúrate de ingresar primero el nombre de usuario o proporcionar un loginName como parámetro de búsqueda.",
"sessionExpired": "Tu sesión actual ha expirado. Por favor, inicia sesión de nuevo.",
"failedLoading": "No se pudieron cargar los datos. Por favor, inténtalo de nuevo."
"failedLoading": "No se pudieron cargar los datos. Por favor, inténtalo de nuevo.",
"tryagain": "Intentar de nuevo"
}
}

View File

@@ -173,6 +173,7 @@
"error": {
"unknownContext": "Impossibile ottenere il contesto dell'utente. Assicurati di inserire prima il nome utente o di fornire un loginName come parametro di ricerca.",
"sessionExpired": "La tua sessione attuale è scaduta. Effettua nuovamente l'accesso.",
"failedLoading": "Impossibile caricare i dati. Riprova."
"failedLoading": "Impossibile caricare i dati. Riprova.",
"tryagain": "Riprova"
}
}

View File

@@ -57,36 +57,36 @@
"tinycolor2": "1.4.2"
},
"devDependencies": {
"@bufbuild/buf": "^1.41.0",
"@testing-library/jest-dom": "^6.4.5",
"@bufbuild/buf": "^1.46.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/ms": "0.7.34",
"@types/node": "22.5.5",
"@types/react": "18.3.7",
"@types/react-dom": "18.3.0",
"@types/node": "22.9.0",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@types/tinycolor2": "1.4.3",
"@types/uuid": "^10.0.0",
"@vercel/git-hooks": "1.0.0",
"@zitadel/prettier-config": "workspace:*",
"@zitadel/tsconfig": "workspace:*",
"autoprefixer": "10.4.20",
"concurrently": "^9.0.1",
"cypress": "^13.14.2",
"del-cli": "5.1.0",
"concurrently": "^9.1.0",
"cypress": "^13.15.2",
"del-cli": "6.0.0",
"env-cmd": "^10.1.0",
"eslint-config-zitadel": "workspace:*",
"grpc-tools": "1.12.4",
"jsdom": "^25.0.0",
"jsdom": "^25.0.1",
"lint-staged": "15.2.10",
"make-dir-cli": "4.0.0",
"nodemon": "^3.1.5",
"postcss": "8.4.47",
"prettier-plugin-tailwindcss": "0.6.6",
"sass": "^1.79.1",
"nodemon": "^3.1.7",
"postcss": "8.4.49",
"prettier-plugin-tailwindcss": "0.6.8",
"sass": "^1.80.7",
"start-server-and-test": "^2.0.8",
"tailwindcss": "3.4.13",
"ts-proto": "^2.2.0",
"typescript": "^5.6.2",
"tailwindcss": "3.4.14",
"ts-proto": "^2.2.7",
"typescript": "^5.6.3",
"zitadel-tailwind-config": "workspace:*"
}
}

View File

@@ -2,6 +2,7 @@
import { Boundary } from "@/components/boundary";
import { Button } from "@/components/button";
import { useTranslations } from "next-intl";
import { useEffect } from "react";
export default function Error({ error, reset }: any) {
@@ -9,6 +10,8 @@ export default function Error({ error, reset }: any) {
console.log("logging error:", error);
}, [error]);
const t = useTranslations("error");
return (
<Boundary labels={["Login Error"]} color="red">
<div className="space-y-4">
@@ -16,7 +19,7 @@ export default function Error({ error, reset }: any) {
<strong className="font-bold">Error:</strong> {error?.message}
</div>
<div>
<Button onClick={() => reset()}>Try Again</Button>
<Button onClick={() => reset()}>{t("tryagain")}</Button>
</div>
</div>
</Boundary>

View File

@@ -3,6 +3,7 @@
import { Boundary } from "@/components/boundary";
import { Button } from "@/components/button";
import { ThemeWrapper } from "@/components/theme-wrapper";
import { useTranslations } from "next-intl";
export default function GlobalError({
error,
@@ -11,6 +12,8 @@ export default function GlobalError({
error: Error & { digest?: string };
reset: () => void;
}) {
const t = useTranslations("error");
return (
// global-error must include html and body tags
<html>
@@ -22,7 +25,7 @@ export default function GlobalError({
<span className="font-bold">Error:</span> {error?.message}
</div>
<div>
<Button onClick={() => reset()}>Try Again</Button>
<Button onClick={() => reset()}>{t("tryagain")}</Button>
</div>
</div>
</Boundary>

View File

@@ -61,11 +61,13 @@ export function ChangePasswordForm({
const changeResponse = await setMyPassword({
sessionId: sessionId,
password: values.password,
}).catch(() => {
setError("Could not change password");
});
setLoading(false);
})
.catch(() => {
setError("Could not change password");
})
.finally(() => {
setLoading(false);
});
if (changeResponse && "error" in changeResponse) {
setError(changeResponse.error);
@@ -86,13 +88,14 @@ export function ChangePasswordForm({
password: { password: values.password },
}),
authRequestId,
}).catch(() => {
setLoading(false);
setError("Could not verify password");
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not verify password");
return;
})
.finally(() => {
setLoading(false);
});
if (
passwordResponse &&

View File

@@ -35,11 +35,12 @@ export function IdpSignin({
},
authRequestId,
}).catch((error) => {
setError(error.message);
return;
});
setLoading(false);
setError(error.message);
return;
})
.finally(() => {
setLoading(false);
});
}, []);
return (

View File

@@ -55,13 +55,14 @@ export function InviteForm({
firstName: values.firstname,
lastName: values.lastname,
organization: organization,
}).catch(() => {
setError("Could not create invitation Code");
setLoading(false);
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not create invitation Code");
return;
})
.finally(() => {
setLoading(false);
});
if (response && typeof response === "object" && "error" in response) {
setError(response.error);

View File

@@ -57,11 +57,10 @@ export function LoginOTP({
initialized.current = true;
setLoading(true);
updateSessionForOTPChallenge()
.then((response) => {
setLoading(false);
})
.catch((error) => {
setError(error);
})
.finally(() => {
setLoading(false);
});
}
@@ -89,12 +88,13 @@ export function LoginOTP({
organization,
challenges,
authRequestId,
}).catch((error) => {
setError(error.message ?? "Could not request OTP challenge");
setLoading(false);
});
setLoading(false);
})
.catch((error) => {
setError(error.message ?? "Could not request OTP challenge");
})
.finally(() => {
setLoading(false);
});
return response;
}
@@ -139,13 +139,14 @@ export function LoginOTP({
organization,
checks,
authRequestId,
}).catch(() => {
setError("Could not verify OTP code");
setLoading(false);
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not verify OTP code");
return;
})
.finally(() => {
setLoading(false);
});
return response;
}
@@ -206,11 +207,10 @@ export function LoginOTP({
onClick={() => {
setLoading(true);
updateSessionForOTPChallenge()
.then((response) => {
setLoading(false);
})
.catch((error) => {
setError(error);
})
.finally(() => {
setLoading(false);
});
}}

View File

@@ -61,16 +61,17 @@ export function LoginPasskey({
}
return submitLoginAndContinue(pK)
.then(() => {
setLoading(false);
})
.catch((error) => {
setError(error);
})
.finally(() => {
setLoading(false);
});
})
.catch((error) => {
setError(error);
})
.finally(() => {
setLoading(false);
});
}
@@ -94,10 +95,13 @@ export function LoginPasskey({
},
}),
authRequestId,
}).catch(() => {
setError("Could not request passkey challenge");
});
setLoading(false);
})
.catch(() => {
setError("Could not request passkey challenge");
})
.finally(() => {
setLoading(false);
});
return session;
}
@@ -112,11 +116,13 @@ export function LoginPasskey({
webAuthN: { credentialAssertionData: data },
} as Checks,
authRequestId,
}).catch(() => {
setError("Could not verify passkey");
});
setLoading(false);
})
.catch(() => {
setError("Could not verify passkey");
})
.finally(() => {
setLoading(false);
});
return response;
}
@@ -243,7 +249,9 @@ export function LoginPasskey({
variant={ButtonVariants.Primary}
disabled={loading}
onClick={async () => {
const response = await updateSessionForChallenge();
const response = await updateSessionForChallenge().finally(() => {
setLoading(false);
});
const pK =
response?.challenges?.webAuthN?.publicKeyCredentialRequestOptions
@@ -251,15 +259,16 @@ export function LoginPasskey({
if (!pK) {
setError("Could not request passkey challenge");
setLoading(false);
return;
}
setLoading(true);
return submitLoginAndContinue(pK)
.then(() => {
setLoading(false);
})
.catch((error) => {
setError(error);
})
.finally(() => {
setLoading(false);
});
}}

View File

@@ -60,13 +60,14 @@ export function PasswordForm({
}),
authRequestId,
forceMfa: loginSettings?.forceMfa,
}).catch(() => {
setLoading(false);
setError("Could not verify password");
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not verify password");
return;
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response && response.error) {
setError(response.error);
@@ -83,12 +84,14 @@ export function PasswordForm({
const response = await resetPassword({
loginName,
organization,
}).catch(() => {
setError("Could not reset password");
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not reset password");
return;
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response) {
setError(response.error);

View File

@@ -67,20 +67,20 @@ export function RegisterFormWithoutPassword({
lastName: values.lastname,
organization: organization,
authRequestId: authRequestId,
}).catch((error) => {
setError("Could not register user");
setLoading(false);
return;
});
})
.catch(() => {
setError("Could not register user");
return;
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response) {
setError(response.error);
setLoading(false);
return;
}
setLoading(false);
return response;
}
@@ -173,10 +173,7 @@ export function RegisterFormWithoutPassword({
variant={ButtonVariants.Primary}
disabled={loading || !formState.isValid || !tosAndPolicyAccepted}
onClick={handleSubmit((values) =>
submitAndContinue(
values,
selected.name === methods[0].name ? false : true,
),
submitAndContinue(values, !(selected.name === methods[0].name)),
)}
>
{loading && <Spinner className="h-5 w-5 mr-2" />}

View File

@@ -50,11 +50,14 @@ export function RegisterPasskey({
passkeyName,
publicKeyCredential,
sessionId,
}).catch(() => {
setError("Could not verify Passkey");
});
})
.catch(() => {
setError("Could not verify Passkey");
})
.finally(() => {
setLoading(false);
});
setLoading(false);
return response;
}
@@ -62,10 +65,13 @@ export function RegisterPasskey({
setLoading(true);
const resp = await registerPasskeyLink({
sessionId,
}).catch(() => {
setError("Could not register passkey");
});
setLoading(false);
})
.catch(() => {
setError("Could not register passkey");
})
.finally(() => {
setLoading(false);
});
if (!resp) {
setError("An error on registering passkey");

View File

@@ -47,16 +47,18 @@ export function RegisterU2f({
passkeyName,
publicKeyCredential,
sessionId,
}).catch(() => {
setError("An error on verifying passkey occurred");
});
})
.catch(() => {
setError("An error on verifying passkey occurred");
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response && response?.error) {
setError(response?.error);
}
setLoading(false);
return response;
}
@@ -65,11 +67,13 @@ export function RegisterU2f({
setLoading(true);
const response = await addU2F({
sessionId,
}).catch(() => {
setError("An error on registering passkey");
});
setLoading(false);
})
.catch(() => {
setError("An error on registering passkey");
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response && response?.error) {
setError(response?.error);
@@ -115,7 +119,6 @@ export function RegisterU2f({
!(resp as any).rawId
) {
setError("An error on registering passkey");
setLoading(false);
return;
}
@@ -139,7 +142,6 @@ export function RegisterU2f({
const submitResponse = await submitVerify(u2fId, "", data, sessionId);
if (!submitResponse) {
setLoading(false);
setError("An error on verifying passkey");
return;
}
@@ -177,8 +179,6 @@ export function RegisterU2f({
router.push(urlToContinue);
}
setLoading(false);
}
return (

View File

@@ -40,11 +40,14 @@ export function SessionItem({
setLoading(true);
const response = await cleanupSession({
sessionId: id,
}).catch((error) => {
setError(error.message);
});
})
.catch((error) => {
setError(error.message);
})
.finally(() => {
setLoading(false);
});
setLoading(false);
return response;
}

View File

@@ -71,13 +71,14 @@ export function SetPasswordForm({
payload = { ...payload, code: values.code };
}
const changeResponse = await changePassword(payload).catch(() => {
setError("Could not set password");
setLoading(false);
return;
});
setLoading(false);
const changeResponse = await changePassword(payload)
.catch(() => {
setError("Could not set password");
return;
})
.finally(() => {
setLoading(false);
});
if (changeResponse && "error" in changeResponse) {
setError(changeResponse.error);
@@ -107,13 +108,14 @@ export function SetPasswordForm({
password: { password: values.password },
}),
authRequestId,
}).catch((error) => {
setLoading(false);
setError("Could not verify password");
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not verify password");
return;
})
.finally(() => {
setLoading(false);
});
if (
passwordResponse &&

View File

@@ -65,11 +65,13 @@ export function SetRegisterPasswordForm({
organization: organization,
authRequestId: authRequestId,
password: values.password,
}).catch(() => {
setError("Could not register user");
});
setLoading(false);
})
.catch(() => {
setError("Could not register user");
})
.finally(() => {
setLoading(false);
});
if (response && "error" in response) {
setError(response.error);

View File

@@ -53,11 +53,13 @@ export function SignInWithIdp({
`${host}/idp/${provider}/success?` + new URLSearchParams(params),
failureUrl:
`${host}/idp/${provider}/failure?` + new URLSearchParams(params),
}).catch(() => {
setError("Could not start IDP flow");
});
setLoading(false);
})
.catch(() => {
setError("Could not start IDP flow");
})
.finally(() => {
setLoading(false);
});
return response;
}

View File

@@ -51,7 +51,6 @@ export function TotpRegister({
setLoading(true);
return verifyTOTP(values.code, loginName, organization)
.then((response) => {
setLoading(false);
// if attribute is set, validate MFA after it is setup, otherwise proceed as usual (when mfa is enforced to login)
if (checkAfter) {
const params = new URLSearchParams({});
@@ -96,8 +95,10 @@ export function TotpRegister({
}
})
.catch((e) => {
setLoading(false);
setError(e.message);
})
.finally(() => {
setLoading(false);
});
}

View File

@@ -52,11 +52,13 @@ export function UsernameForm({
loginName: values.loginName,
organization,
authRequestId,
}).catch(() => {
setError("An internal error occurred");
});
setLoading(false);
})
.catch(() => {
setError("An internal error occurred");
})
.finally(() => {
setLoading(false);
});
if (res?.error) {
setError(res.error);

View File

@@ -41,13 +41,15 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
const response = await resendVerification({
userId,
isInvite: isInvite,
}).catch(() => {
setError("Could not resend email");
setLoading(false);
return;
});
})
.catch(() => {
setError("Could not resend email");
return;
})
.finally(() => {
setLoading(false);
});
setLoading(false);
return response;
}
@@ -61,13 +63,14 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
code: value.code,
userId,
isInvite: isInvite,
}).catch((error) => {
setError("Could not verify user");
setLoading(false);
return;
});
setLoading(false);
})
.catch(() => {
setError("Could not verify user");
return;
})
.finally(() => {
setLoading(false);
});
},
[isInvite, userId],
);

View File

@@ -29,13 +29,14 @@ export function VerifyRedirectButton({
await sendVerificationRedirectWithoutCheck({
userId,
authRequestId,
}).catch((error) => {
setError("Could not verify user");
setLoading(false);
return;
});
setLoading(false);
})
.catch((error) => {
setError("Could not verify user");
return;
})
.finally(() => {
setLoading(false);
});
}
return (

View File

@@ -186,11 +186,6 @@ export async function sendLoginname(command: SendLoginnameCommand) {
redirect("/verify?" + paramsVerify);
}
// what to do with users with valid email but no auth methods? redirect to /authenticator/set?
// return {
// error:
// "User has no available authentication methods. Contact your administrator to setup authentication for the requested user.",
// };
const paramsAuthenticatorSetup = new URLSearchParams({
loginName: session.factors?.user?.loginName,

View File

@@ -29,19 +29,19 @@
}
},
"devDependencies": {
"@changesets/cli": "^2.27.8",
"@playwright/test": "^1.48.1",
"@types/node": "^22.7.5",
"@vitejs/plugin-react": "^4.2.1",
"@changesets/cli": "^2.27.9",
"@playwright/test": "^1.48.2",
"@types/node": "^22.9.0",
"@vitejs/plugin-react": "^4.3.3",
"@zitadel/prettier-config": "workspace:*",
"eslint": "8.57.1",
"eslint-config-zitadel": "workspace:*",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^4.0.0",
"tsup": "^8.3.0",
"turbo": "2.1.2",
"typescript": "^5.6.2",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.1.1"
"prettier-plugin-organize-imports": "^4.1.0",
"tsup": "^8.3.5",
"turbo": "2.2.3",
"typescript": "^5.6.3",
"vite-tsconfig-paths": "^5.1.2",
"vitest": "^2.1.4"
}
}

View File

@@ -38,7 +38,7 @@
},
"devDependencies": {
"@connectrpc/connect": "^2.0.0-alpha.1",
"@types/node": "^22.5.5",
"@types/node": "^22.9.0",
"@zitadel/client": "workspace:*",
"@zitadel/tsconfig": "workspace:*",
"eslint-config-zitadel": "workspace:*"

View File

@@ -18,6 +18,6 @@
"@bufbuild/protobuf": "^2.0.0"
},
"devDependencies": {
"@bufbuild/buf": "^1.41.0"
"@bufbuild/buf": "^1.46.0"
}
}

View File

@@ -4,7 +4,7 @@
"private": true,
"main": "index.js",
"devDependencies": {
"tailwindcss": "^3.4.12",
"tailwindcss": "^3.4.14",
"@tailwindcss/forms": "0.5.3"
}
}

2330
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff