Skip to content

Commit 0ee810a

Browse files
authored
feat(console): add password not enabled notification (#7201)
add password not enabled notificaiton
1 parent bae3c78 commit 0ee810a

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { SignInIdentifier, type SignInExperience } from '@logto/schemas';
2+
import { useMemo } from 'react';
3+
import { useTranslation } from 'react-i18next';
4+
5+
import { isDevFeaturesEnabled } from '@/consts/env';
6+
import InlineNotification from '@/ds-components/InlineNotification';
7+
8+
import { signUpFormDataParser } from '../utils/parser';
9+
10+
type Props = {
11+
readonly after: SignInExperience;
12+
readonly className?: string;
13+
};
14+
15+
function PasswordDisabledNotification({ after, className }: Props) {
16+
const { signUp } = after;
17+
const { identifiers, password } = signUpFormDataParser.fromSignUp(signUp);
18+
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
19+
20+
const shouldShowNotification = useMemo(() => {
21+
if (!isDevFeaturesEnabled) {
22+
return false;
23+
}
24+
25+
return (
26+
identifiers.length === 1 &&
27+
identifiers[0]?.identifier === SignInIdentifier.Username &&
28+
!password
29+
);
30+
}, [identifiers, password]);
31+
32+
if (!shouldShowNotification) {
33+
return null;
34+
}
35+
36+
return (
37+
<InlineNotification className={className}>
38+
{t('sign_in_exp.sign_up_and_sign_in.tip.password_disabled_notification')}
39+
</InlineNotification>
40+
);
41+
}
42+
43+
export default PasswordDisabledNotification;

packages/console/src/pages/SignInExperience/PageContent/SignUpAndSignInChangePreview/index.module.scss

+4
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
}
2828
}
2929
}
30+
31+
.notification {
32+
margin-top: _.unit(3);
33+
}
3034
}

packages/console/src/pages/SignInExperience/PageContent/SignUpAndSignInChangePreview/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { SignInExperience } from '@logto/schemas';
22
import { useTranslation } from 'react-i18next';
33

4+
import PasswordDisabledNotification from './PasswordDisabledNotification';
45
import SignUpAndSignInDiffSection from './SignUpAndSignInDiffSection';
56
import styles from './index.module.scss';
67

@@ -25,6 +26,7 @@ function SignUpAndSignInChangePreview({ before, after }: Props) {
2526
<SignUpAndSignInDiffSection isAfter before={before} after={after} />
2627
</div>
2728
</div>
29+
<PasswordDisabledNotification after={after} className={styles.notification} />
2830
</div>
2931
);
3032
}

packages/phrases/src/locales/en/translation/admin-console/sign-in-exp/sign-up-and-sign-in.ts

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const sign_up_and_sign_in = {
5656
'This is essential as you have only enabled the option to provide verification code when signing up. You’re free to uncheck the box when password set-up is allowed at the sign-up process.',
5757
delete_sign_in_method:
5858
'This is essential as you have selected {{identifier}} as a required identifier.',
59+
password_disabled_notification:
60+
'The "Create your password" option is disabled for username sign-up, which may prevent users from signing in. Confirm to proceed with saving.',
5961
},
6062
advanced_options: {
6163
title: 'ADVANCED OPTIONS',

0 commit comments

Comments
 (0)