mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:04:25 +00:00
return error as object from server actions
This commit is contained in:
@@ -33,9 +33,6 @@ const secureHeaders = [
|
|||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true, // Recommended for the `pages` directory, default in `app`.
|
reactStrictMode: true, // Recommended for the `pages` directory, default in `app`.
|
||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
experimental: {
|
|
||||||
serverComponentsErrorOverride: true,
|
|
||||||
},
|
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!session.factors?.user?.id) {
|
if (!session.factors?.user?.id) {
|
||||||
throw Error("Could not create session for user");
|
return { error: "Could not create session for user" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const methods = await listAuthenticationMethodTypes(
|
const methods = await listAuthenticationMethodTypes(
|
||||||
@@ -87,9 +87,10 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!methods.authMethodTypes || !methods.authMethodTypes.length) {
|
if (!methods.authMethodTypes || !methods.authMethodTypes.length) {
|
||||||
throw Error(
|
return {
|
||||||
|
error:
|
||||||
"User has no available authentication methods. Contact your administrator to setup authentication for the requested user.",
|
"User has no available authentication methods. Contact your administrator to setup authentication for the requested user.",
|
||||||
);
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methods.authMethodTypes.length == 1) {
|
if (methods.authMethodTypes.length == 1) {
|
||||||
@@ -175,7 +176,7 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
|||||||
// TODO: do we need to handle login hints for IDPs here?
|
// TODO: do we need to handle login hints for IDPs here?
|
||||||
await redirectUserToSingleIDPIfAvailable();
|
await redirectUserToSingleIDPIfAvailable();
|
||||||
|
|
||||||
throw Error("Could not find user");
|
return { error: "Could not find user" };
|
||||||
} else if (
|
} else if (
|
||||||
loginSettings?.allowRegister &&
|
loginSettings?.allowRegister &&
|
||||||
loginSettings?.allowUsernamePassword
|
loginSettings?.allowUsernamePassword
|
||||||
@@ -232,5 +233,5 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
|||||||
return redirect("/password?" + new URLSearchParams(paramsPasswordDefault));
|
return redirect("/password?" + new URLSearchParams(paramsPasswordDefault));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Error("Could not find user");
|
return { error: "Could not find user" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,13 @@ export default function UsernameForm({
|
|||||||
organization,
|
organization,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch((error: Error) => {
|
}).catch((error: Error) => {
|
||||||
setError(error.message ?? "An internal error occurred");
|
setError("An internal error occurred");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (res?.error) {
|
||||||
|
setError(res.error);
|
||||||
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user