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 />
|
<NotSet />
|
||||||
),
|
),
|
||||||
action: {
|
action: {
|
||||||
name: 'profile.change',
|
name: user.primaryEmail ? 'profile.change' : 'profile.link',
|
||||||
handler: () => {
|
handler: () => {
|
||||||
navigate('link-email', {
|
navigate('link-email', {
|
||||||
state: { email: user.primaryEmail, action: 'changeEmail' },
|
state: { email: user.primaryEmail, action: 'changeEmail' },
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { emailRegEx } from '@logto/core-kit';
|
import { emailRegEx } from '@logto/core-kit';
|
||||||
|
import { conditional } from '@silverhand/essentials';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
@ -43,6 +44,8 @@ const LinkEmailModal = () => {
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentEmail = conditional(checkLocationState(state) && state.email);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MainFlowLikeModal
|
<MainFlowLikeModal
|
||||||
title="profile.link_account.link_email"
|
title="profile.link_account.link_email"
|
||||||
|
@ -54,7 +57,8 @@ const LinkEmailModal = () => {
|
||||||
required: t('profile.link_account.email_required'),
|
required: t('profile.link_account.email_required'),
|
||||||
pattern: { value: emailRegEx, message: t('profile.link_account.invalid_email') },
|
pattern: { value: emailRegEx, message: t('profile.link_account.invalid_email') },
|
||||||
validate: (value) =>
|
validate: (value) =>
|
||||||
(checkLocationState(state) && state.email !== value) ||
|
!currentEmail ||
|
||||||
|
currentEmail !== value ||
|
||||||
t('profile.link_account.identical_email_address'),
|
t('profile.link_account.identical_email_address'),
|
||||||
})}
|
})}
|
||||||
errorMessage={errors.email?.message}
|
errorMessage={errors.email?.message}
|
||||||
|
|
Loading…
Add table
Reference in a new issue