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:
parent
11471c4308
commit
3d57b94e30
2 changed files with 6 additions and 2 deletions
|
@ -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' },
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Add table
Reference in a new issue