mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 23:55:36 +00:00
fix: leave team (#5554)
* chore: fe copywrite * feat: auto accept invitation when login * perf: only show forbidden filter in sync mode * chore: auto accept invitation
This commit is contained in:
@@ -4,21 +4,35 @@ import { serviceSideProps } from '@/web/common/i18n/utils';
|
||||
import { clearToken } from '@/web/support/user/auth';
|
||||
import { useMount } from 'ahooks';
|
||||
import LoginModal from '@/pageComponents/login/LoginModal';
|
||||
import { postAcceptInvitationLink } from '@/web/support/user/team/api';
|
||||
import type { ResLogin } from '@/global/support/api/userRes';
|
||||
|
||||
const Login = () => {
|
||||
const router = useRouter();
|
||||
const { lastRoute = '' } = router.query as { lastRoute: string };
|
||||
|
||||
const loginSuccess = useCallback(() => {
|
||||
const decodeLastRoute = decodeURIComponent(lastRoute);
|
||||
const loginSuccess = useCallback(
|
||||
async (res: ResLogin) => {
|
||||
const decodeLastRoute = decodeURIComponent(lastRoute);
|
||||
const navigateTo = await (async () => {
|
||||
if (res.user.team.status !== 'active') {
|
||||
if (decodeLastRoute.includes('/account/team?invitelinkid=')) {
|
||||
const id = decodeLastRoute.split('invitelinkid=')[1];
|
||||
await postAcceptInvitationLink(id);
|
||||
return '/dashboard/apps';
|
||||
}
|
||||
}
|
||||
return decodeLastRoute &&
|
||||
!decodeLastRoute.includes('/login') &&
|
||||
decodeLastRoute.startsWith('/')
|
||||
? lastRoute
|
||||
: '/dashboard/apps';
|
||||
})();
|
||||
|
||||
const navigateTo =
|
||||
decodeLastRoute && !decodeLastRoute.includes('/login') && decodeLastRoute.startsWith('/')
|
||||
? lastRoute
|
||||
: '/dashboard/apps';
|
||||
|
||||
router.push(navigateTo);
|
||||
}, [lastRoute, router]);
|
||||
router.replace(navigateTo);
|
||||
},
|
||||
[lastRoute, router]
|
||||
);
|
||||
|
||||
useMount(() => {
|
||||
clearToken();
|
||||
|
Reference in New Issue
Block a user