Implement Error page

This commit is contained in:
Joseph Garrone
2021-03-06 23:03:03 +01:00
parent 307650aaea
commit 1d07fd7675
7 changed files with 32 additions and 11 deletions

View File

@ -1,4 +1,15 @@
<script>const _= <script>const _=
{ {
"client": (function (){
<#if client??>
return {
"baseUrl": "${(client.baseUrl!'')?no_esc}" || undefined
};
</#if>
return undefined;
})()
} }
</script> </script>

View File

@ -31,7 +31,7 @@
"pageRedirectUri": "${(pageRedirectUri!'')?no_esc}" || undefined, "pageRedirectUri": "${(pageRedirectUri!'')?no_esc}" || undefined,
"actionUri": "${(actionUri!'')?no_esc}" || undefined, "actionUri": "${(actionUri!'')?no_esc}" || undefined,
"client": { "client": {
"baseUrl": "${(actionUri!'')?no_esc}" || undefined "baseUrl": "${(client.baseUrl!'')?no_esc}" || undefined
} }
} }
</script> </script>

View File

@ -7,6 +7,7 @@
"realm": { "realm": {
"loginWithEmailAllowed": ${realm.loginWithEmailAllowed?c}, "loginWithEmailAllowed": ${realm.loginWithEmailAllowed?c},
"rememberMe": ${realm.rememberMe?c}, "rememberMe": ${realm.rememberMe?c},
"password": ${realm.password?c},
"resetPasswordAllowed": ${realm.resetPasswordAllowed?c}, "resetPasswordAllowed": ${realm.resetPasswordAllowed?c},
"registrationAllowed": ${realm.registrationAllowed?c} "registrationAllowed": ${realm.registrationAllowed?c}
}, },

View File

@ -11,7 +11,6 @@
"displayName": "${realm.displayName!''}" || undefined, "displayName": "${realm.displayName!''}" || undefined,
"displayNameHtml": "${realm.displayNameHtml!''}" || undefined, "displayNameHtml": "${realm.displayNameHtml!''}" || undefined,
"internationalizationEnabled": ${realm.internationalizationEnabled?c}, "internationalizationEnabled": ${realm.internationalizationEnabled?c},
"password": ${realm.password?c},
"registrationEmailAsUsername": ${realm.registrationEmailAsUsername?c}, "registrationEmailAsUsername": ${realm.registrationEmailAsUsername?c},
}, },
"locale": (function (){ "locale": (function (){

View File

@ -24,12 +24,17 @@ export const Error = memo((props: KcProps) => {
displayMessage={false} displayMessage={false}
headerNode={t("errorTitle")} headerNode={t("errorTitle")}
formNode={ formNode={
<div id="kc-error-message"> <div id="kc-error-message">
<p className="instruction">{message.summary}</p> <p className="instruction">{message.summary}</p>
<#if client?? && client.baseUrl?has_content> {
<p><a id="backToApplication" href="${client.baseUrl}">${kcSanitize(msg("backToApplication"))?no_esc}</a></p> client !== undefined && client.baseUrl !== undefined &&
</#if> <p>
</div> <a id="backToApplication" href={client.baseUrl}>
{t("backToApplication")}
</a>
</p>
}
</div>
} }
/> />
); );

View File

@ -6,6 +6,7 @@ import type { KcProps } from "./KcProps";
import { Login } from "./Login"; import { Login } from "./Login";
import { Register } from "./Register"; import { Register } from "./Register";
import { Info } from "./Info"; import { Info } from "./Info";
import { Error } from "./Error";
export const KcApp = memo((props: KcProps) => { export const KcApp = memo((props: KcProps) => {
@ -16,6 +17,7 @@ export const KcApp = memo((props: KcProps) => {
case "login.ftl": return <Login {...props} />; case "login.ftl": return <Login {...props} />;
case "register.ftl": return <Register {...props} />; case "register.ftl": return <Register {...props} />;
case "info.ftl": return <Info {...props} />; case "info.ftl": return <Info {...props} />;
case "error.ftl": return <Error {...props} />;
} }
}); });

View File

@ -25,8 +25,7 @@ export declare namespace KcContext {
displayName?: string; displayName?: string;
displayNameHtml?: string; displayNameHtml?: string;
internationalizationEnabled: boolean; internationalizationEnabled: boolean;
password: boolean; registrationEmailAsUsername: boolean; //<---
registrationEmailAsUsername: boolean;
}; };
/** Undefined if !realm.internationalizationEnabled */ /** Undefined if !realm.internationalizationEnabled */
locale?: { locale?: {
@ -63,6 +62,7 @@ export declare namespace KcContext {
realm: { realm: {
loginWithEmailAllowed: boolean; loginWithEmailAllowed: boolean;
rememberMe: boolean; rememberMe: boolean;
password: boolean;
resetPasswordAllowed: boolean; resetPasswordAllowed: boolean;
registrationAllowed: boolean; registrationAllowed: boolean;
}; };
@ -132,7 +132,10 @@ export declare namespace KcContext {
}; };
export type Error = Template & { export type Error = Template & {
pageId: "error.ftl" pageId: "error.ftl";
client?: {
baseUrl?: string;
}
}; };
} }