mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:23:16 +00:00
return error as object from server actions
This commit is contained in:
@@ -33,9 +33,6 @@ const secureHeaders = [
|
||||
const nextConfig = {
|
||||
reactStrictMode: true, // Recommended for the `pages` directory, default in `app`.
|
||||
swcMinify: true,
|
||||
experimental: {
|
||||
serverComponentsErrorOverride: true,
|
||||
},
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
);
|
||||
|
||||
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(
|
||||
@@ -87,9 +87,10 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
);
|
||||
|
||||
if (!methods.authMethodTypes || !methods.authMethodTypes.length) {
|
||||
throw Error(
|
||||
"User has no available authentication methods. Contact your administrator to setup authentication for the requested user.",
|
||||
);
|
||||
return {
|
||||
error:
|
||||
"User has no available authentication methods. Contact your administrator to setup authentication for the requested user.",
|
||||
};
|
||||
}
|
||||
|
||||
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?
|
||||
await redirectUserToSingleIDPIfAvailable();
|
||||
|
||||
throw Error("Could not find user");
|
||||
return { error: "Could not find user" };
|
||||
} else if (
|
||||
loginSettings?.allowRegister &&
|
||||
loginSettings?.allowUsernamePassword
|
||||
@@ -232,5 +233,5 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
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,
|
||||
authRequestId,
|
||||
}).catch((error: Error) => {
|
||||
setError(error.message ?? "An internal error occurred");
|
||||
setError("An internal error occurred");
|
||||
});
|
||||
|
||||
if (res?.error) {
|
||||
setError(res.error);
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user