snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
50
apps/meteor/client/views/invite/InvitePage.tsx
Normal file
50
apps/meteor/client/views/invite/InvitePage.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { HeroLayout, HeroLayoutTitle } from '@rocket.chat/layout';
|
||||
import { useRouteParameter, useUserId } from '@rocket.chat/ui-contexts';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import LoginPage from '../root/MainLayout/LoginPage';
|
||||
import PageLoading from '../root/PageLoading';
|
||||
import { useInviteTokenMutation } from './hooks/useInviteTokenMutation';
|
||||
import { useSamlInviteToken } from './hooks/useSamlInviteToken';
|
||||
import { useValidateInviteQuery } from './hooks/useValidateInviteQuery';
|
||||
|
||||
const InvitePage = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const token = useRouteParameter('hash');
|
||||
const userId = useUserId();
|
||||
const validateInvite = useValidateInviteQuery(token);
|
||||
const [, setToken] = useSamlInviteToken();
|
||||
const tokenRef = useRef('');
|
||||
|
||||
const getInviteRoomMutation = useInviteTokenMutation();
|
||||
|
||||
useEffect(() => {
|
||||
// TODO: this is so hacky, get from the url and set the storage
|
||||
setToken(token || null);
|
||||
}, [setToken, token]);
|
||||
|
||||
useEffect(() => {
|
||||
if (userId && token && !getInviteRoomMutation.submittedAt && tokenRef.current !== token) {
|
||||
tokenRef.current = token;
|
||||
getInviteRoomMutation.mutate(token);
|
||||
}
|
||||
}, [getInviteRoomMutation, setToken, token, userId]);
|
||||
|
||||
if (validateInvite.isPending) {
|
||||
return <PageLoading />;
|
||||
}
|
||||
|
||||
if (validateInvite.isSuccess && validateInvite.data) {
|
||||
return <LoginPage />;
|
||||
}
|
||||
|
||||
return (
|
||||
<HeroLayout>
|
||||
<HeroLayoutTitle>{t('Invalid_or_expired_invite_token')}</HeroLayoutTitle>
|
||||
</HeroLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default InvitePage;
|
||||
22
apps/meteor/client/views/invite/SecretURLPage.tsx
Normal file
22
apps/meteor/client/views/invite/SecretURLPage.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useUserId, useRouter } from '@rocket.chat/ui-contexts';
|
||||
import RegistrationPageRouter from '@rocket.chat/web-ui-registration';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const SecretURLPage = () => {
|
||||
const uid = useUserId();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (uid) {
|
||||
router.navigate('/home');
|
||||
}
|
||||
}, [uid, router]);
|
||||
|
||||
if (uid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <RegistrationPageRouter defaultRoute='secret-register' />;
|
||||
};
|
||||
|
||||
export default SecretURLPage;
|
||||
@@ -0,0 +1,35 @@
|
||||
import { useEndpoint, useRouter, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const useInviteTokenMutation = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
const getInviteRoom = useEndpoint('POST', '/v1/useInviteToken');
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ['inviteToken'],
|
||||
mutationFn: (token: string) => getInviteRoom({ token }),
|
||||
onSuccess: (result) => {
|
||||
if (!result.room.name) {
|
||||
dispatchToastMessage({ type: 'error', message: t('Failed_to_activate_invite_token') });
|
||||
router.navigate('/home');
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.room.t === 'p') {
|
||||
router.navigate(`/group/${result.room.name}`);
|
||||
return;
|
||||
}
|
||||
|
||||
router.navigate(`/channel/${result.room.name}`);
|
||||
},
|
||||
onError: () => {
|
||||
dispatchToastMessage({ type: 'error', message: t('Failed_to_activate_invite_token') });
|
||||
router.navigate('/home');
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { useSessionStorage } from '@rocket.chat/fuselage-hooks';
|
||||
import { useRouteParameter } from '@rocket.chat/ui-contexts';
|
||||
|
||||
const KEY = 'saml_invite_token';
|
||||
|
||||
export const useSamlInviteToken = () => {
|
||||
const token = useRouteParameter('hash');
|
||||
return useSessionStorage(KEY, token || null);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
import { useEndpoint, useSessionDispatch, useSetting, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const useValidateInviteQuery = (token: string | undefined) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const registrationForm = useSetting('Accounts_RegistrationForm');
|
||||
|
||||
const setLoginDefaultState = useSessionDispatch('loginDefaultState');
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
const handleValidateInviteToken = useEndpoint('POST', '/v1/validateInviteToken');
|
||||
|
||||
const result = useQuery({
|
||||
queryKey: ['validateInviteToken', token],
|
||||
queryFn: async () => {
|
||||
if (!token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const { valid } = await handleValidateInviteToken({ token });
|
||||
|
||||
// FIXME: decouple this state management from the query
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (registrationForm !== 'Disabled') {
|
||||
setLoginDefaultState('invite-register');
|
||||
} else {
|
||||
setLoginDefaultState('login');
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
throw new Error('Invalid token');
|
||||
}
|
||||
|
||||
return valid;
|
||||
} catch (error) {
|
||||
dispatchToastMessage({ type: 'error', message: t('Failed_to_validate_invite_token') });
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
Reference in New Issue
Block a user