fix: cancel active email page guard

This commit is contained in:
shuai 2022-11-17 14:04:57 +08:00
parent a76e6cee17
commit e733d37b1f
3 changed files with 13 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import { FC, memo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { useSearchParams, useNavigate } from 'react-router-dom';
import { loggedUserInfoStore } from '@/stores';
import { activateAccount } from '@/services';
@ -10,6 +10,7 @@ const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'page_title' });
const [searchParams] = useSearchParams();
const updateUser = loggedUserInfoStore((state) => state.update);
const navigate = useNavigate();
useEffect(() => {
const code = searchParams.get('code');
@ -17,9 +18,11 @@ const Index: FC = () => {
activateAccount(encodeURIComponent(code)).then((res) => {
updateUser(res);
setTimeout(() => {
window.location.replace('/users/account-activation/success');
navigate('/users/account-activation/success', { replace: true });
}, 0);
});
} else {
navigate('/', { replace: true });
}
}, []);
return <PageTitle title={t('account_activation')} />;

View File

@ -167,13 +167,13 @@ const routes: RouteNode[] = [
{
path: 'users/account-activation',
page: 'pages/Users/ActiveEmail',
guard: async () => {
const notActivated = guard.notActivated();
if (notActivated.ok) {
return notActivated;
}
return guard.notLogged();
},
// guard: async () => {
// const notActivated = guard.notActivated();
// if (notActivated.ok) {
// return notActivated;
// }
// return guard.notLogged();
// },
},
{
path: 'users/account-activation/success',

View File

@ -103,6 +103,7 @@ class Request {
return Promise.reject(false);
}
if (status === 403) {
debugger;
// Permission interception
if (data?.type === 'url_expired') {
// url expired