0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-10 22:22:45 -05:00

fix(console): admin user should be able to set email if current email is null (#3301)

This commit is contained in:
Charles Zhao 2023-03-06 19:32:54 +08:00 committed by GitHub
parent 11471c4308
commit 3d57b94e30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -163,7 +163,7 @@ const LinkAccountSection = ({ user, onUpdate }: Props) => {
<NotSet />
),
action: {
name: 'profile.change',
name: user.primaryEmail ? 'profile.change' : 'profile.link',
handler: () => {
navigate('link-email', {
state: { email: user.primaryEmail, action: 'changeEmail' },

View file

@ -1,4 +1,5 @@
import { emailRegEx } from '@logto/core-kit';
import { conditional } from '@silverhand/essentials';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate } from 'react-router-dom';
@ -43,6 +44,8 @@ const LinkEmailModal = () => {
})();
};
const currentEmail = conditional(checkLocationState(state) && state.email);
return (
<MainFlowLikeModal
title="profile.link_account.link_email"
@ -54,7 +57,8 @@ const LinkEmailModal = () => {
required: t('profile.link_account.email_required'),
pattern: { value: emailRegEx, message: t('profile.link_account.invalid_email') },
validate: (value) =>
(checkLocationState(state) && state.email !== value) ||
!currentEmail ||
currentEmail !== value ||
t('profile.link_account.identical_email_address'),
})}
errorMessage={errors.email?.message}