mirror of https://gitee.com/answerdev/answer.git
fix: cancel active email page guard
This commit is contained in:
parent
a76e6cee17
commit
e733d37b1f
|
@ -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')} />;
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -103,6 +103,7 @@ class Request {
|
|||
return Promise.reject(false);
|
||||
}
|
||||
if (status === 403) {
|
||||
debugger;
|
||||
// Permission interception
|
||||
if (data?.type === 'url_expired') {
|
||||
// url expired
|
||||
|
|
Loading…
Reference in New Issue