2023-04-17 04:01:44 +02:00
|
|
|
import React from "react";
|
2024-06-03 00:11:19 +02:00
|
|
|
import type { Meta, StoryObj } from "@storybook/react";
|
2024-06-09 11:53:25 +02:00
|
|
|
import { createKcPageStory } from "../KcPageStory";
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-09 11:53:25 +02:00
|
|
|
const { KcPageStory } = createKcPageStory({ pageId: "login.ftl" });
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
const meta = {
|
2024-06-06 07:28:34 +02:00
|
|
|
title: "login/login.ftl",
|
2024-06-09 11:53:25 +02:00
|
|
|
component: KcPageStory
|
|
|
|
} satisfies Meta<typeof KcPageStory>;
|
2023-04-17 04:01:44 +02:00
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
type Story = StoryObj<typeof meta>;
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const Default: Story = {
|
2024-06-09 11:53:25 +02:00
|
|
|
render: () => <KcPageStory />
|
2024-06-03 00:11:19 +02:00
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-12 23:11:06 +02:00
|
|
|
export const WithInvalidCredential: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
login: {
|
|
|
|
username: "johndoe"
|
|
|
|
},
|
|
|
|
messagesPerField: {
|
|
|
|
// NOTE: The other functions of messagesPerField are derived from get() and
|
|
|
|
// existsError() so they are the only ones that need to mock.
|
|
|
|
existsError: (fieldName: string, ...otherFieldNames: string[]) => {
|
|
|
|
const fieldNames = [fieldName, ...otherFieldNames];
|
|
|
|
return fieldNames.includes("username") || fieldNames.includes("password");
|
|
|
|
},
|
|
|
|
get: (fieldName: string) => {
|
|
|
|
if (fieldName === "username" || fieldName === "password") {
|
|
|
|
return "Invalid username or password.";
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithoutRegistration: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
realm: { registrationAllowed: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithoutRememberMe: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
realm: { rememberMe: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithoutPasswordReset: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
realm: { resetPasswordAllowed: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithEmailAsUsername: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
realm: { loginWithEmailAllowed: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithPresetUsername: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
login: { username: "max.mustermann@mail.com" }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2023-04-17 04:01:44 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
export const WithImmutablePresetUsername: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
auth: {
|
|
|
|
attemptedUsername: "max.mustermann@mail.com",
|
|
|
|
showUsername: true
|
|
|
|
},
|
|
|
|
usernameHidden: true,
|
|
|
|
message: {
|
|
|
|
type: "info",
|
|
|
|
summary: "Please re-authenticate to continue"
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
export const WithSocialProviders: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 00:11:19 +02:00
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
loginUrl: "google",
|
|
|
|
alias: "google",
|
|
|
|
providerId: "google",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Google",
|
|
|
|
iconClasses: "fa fa-google"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "microsoft",
|
|
|
|
alias: "microsoft",
|
|
|
|
providerId: "microsoft",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Microsoft",
|
|
|
|
iconClasses: "fa fa-windows"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "facebook",
|
|
|
|
alias: "facebook",
|
|
|
|
providerId: "facebook",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Facebook",
|
|
|
|
iconClasses: "fa fa-facebook"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "instagram",
|
|
|
|
alias: "instagram",
|
|
|
|
providerId: "instagram",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Instagram",
|
|
|
|
iconClasses: "fa fa-instagram"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "twitter",
|
|
|
|
alias: "twitter",
|
|
|
|
providerId: "twitter",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Twitter",
|
|
|
|
iconClasses: "fa fa-twitter"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "linkedin",
|
|
|
|
alias: "linkedin",
|
|
|
|
providerId: "linkedin",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "LinkedIn",
|
|
|
|
iconClasses: "fa fa-linkedin"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "stackoverflow",
|
|
|
|
alias: "stackoverflow",
|
|
|
|
providerId: "stackoverflow",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Stackoverflow",
|
|
|
|
iconClasses: "fa fa-stack-overflow"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "github",
|
|
|
|
alias: "github",
|
|
|
|
providerId: "github",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Github",
|
|
|
|
iconClasses: "fa fa-github"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "gitlab",
|
|
|
|
alias: "gitlab",
|
|
|
|
providerId: "gitlab",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Gitlab",
|
|
|
|
iconClasses: "fa fa-gitlab"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "bitbucket",
|
|
|
|
alias: "bitbucket",
|
|
|
|
providerId: "bitbucket",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "Bitbucket",
|
|
|
|
iconClasses: "fa fa-bitbucket"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "paypal",
|
|
|
|
alias: "paypal",
|
|
|
|
providerId: "paypal",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "PayPal",
|
|
|
|
iconClasses: "fa fa-paypal"
|
2024-06-03 00:11:19 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "openshift",
|
|
|
|
alias: "openshift",
|
|
|
|
providerId: "openshift",
|
2024-08-14 18:31:55 +02:00
|
|
|
displayName: "OpenShift",
|
|
|
|
iconClasses: "fa fa-cloud"
|
2024-06-03 00:11:19 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2024-06-03 23:25:37 +02:00
|
|
|
|
|
|
|
export const WithoutPasswordField: Story = {
|
|
|
|
render: () => (
|
2024-06-09 11:53:25 +02:00
|
|
|
<KcPageStory
|
2024-06-03 23:25:37 +02:00
|
|
|
kcContext={{
|
|
|
|
realm: { password: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2024-06-12 23:11:06 +02:00
|
|
|
|
|
|
|
export const WithErrorMessage: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
message: {
|
2024-07-04 19:59:28 +02:00
|
|
|
summary: "The time allotted for the connection has elapsed.<br/>The login process will restart from the beginning.",
|
2024-06-12 23:11:06 +02:00
|
|
|
type: "error"
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2024-09-29 04:35:02 -04:00
|
|
|
|
|
|
|
export const WithOneSocialProvider: Story = {
|
|
|
|
render: args => (
|
|
|
|
<KcPageStory
|
|
|
|
{...args}
|
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
loginUrl: "google",
|
|
|
|
alias: "google",
|
|
|
|
providerId: "google",
|
|
|
|
displayName: "Google",
|
|
|
|
iconClasses: "fa fa-google"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
export const WithTwoSocialProviders: Story = {
|
|
|
|
render: args => (
|
|
|
|
<KcPageStory
|
|
|
|
{...args}
|
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
loginUrl: "google",
|
|
|
|
alias: "google",
|
|
|
|
providerId: "google",
|
|
|
|
displayName: "Google",
|
|
|
|
iconClasses: "fa fa-google"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "microsoft",
|
|
|
|
alias: "microsoft",
|
|
|
|
providerId: "microsoft",
|
|
|
|
displayName: "Microsoft",
|
|
|
|
iconClasses: "fa fa-windows"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
export const WithNoSocialProviders: Story = {
|
|
|
|
render: args => (
|
|
|
|
<KcPageStory
|
|
|
|
{...args}
|
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: []
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
export const WithMoreThanTwoSocialProviders: Story = {
|
|
|
|
render: args => (
|
|
|
|
<KcPageStory
|
|
|
|
{...args}
|
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
loginUrl: "google",
|
|
|
|
alias: "google",
|
|
|
|
providerId: "google",
|
|
|
|
displayName: "Google",
|
|
|
|
iconClasses: "fa fa-google"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "microsoft",
|
|
|
|
alias: "microsoft",
|
|
|
|
providerId: "microsoft",
|
|
|
|
displayName: "Microsoft",
|
|
|
|
iconClasses: "fa fa-windows"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "facebook",
|
|
|
|
alias: "facebook",
|
|
|
|
providerId: "facebook",
|
|
|
|
displayName: "Facebook",
|
|
|
|
iconClasses: "fa fa-facebook"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loginUrl: "twitter",
|
|
|
|
alias: "twitter",
|
|
|
|
providerId: "twitter",
|
|
|
|
displayName: "Twitter",
|
|
|
|
iconClasses: "fa fa-twitter"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
export const WithSocialProvidersAndWithoutRememberMe: Story = {
|
|
|
|
render: args => (
|
|
|
|
<KcPageStory
|
|
|
|
{...args}
|
|
|
|
kcContext={{
|
|
|
|
social: {
|
|
|
|
displayInfo: true,
|
|
|
|
providers: [
|
|
|
|
{
|
|
|
|
loginUrl: "google",
|
|
|
|
alias: "google",
|
|
|
|
providerId: "google",
|
|
|
|
displayName: "Google",
|
|
|
|
iconClasses: "fa fa-google"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
realm: { rememberMe: false }
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|