Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CookieManager domain value handled port case #5874

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions app/views/JitsiMeetView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { userAgent } from '../../lib/constants';
import { useAppSelector } from '../../lib/hooks';
import { isIOS } from '../../lib/methods/helpers';
import { getRoomIdFromJitsiCallUrl } from '../../lib/methods/helpers/getRoomIdFromJitsiCall';
import { events, logEvent } from '../../lib/methods/helpers/log';
import log, { events, logEvent } from '../../lib/methods/helpers/log';
import { endVideoConfTimer, initVideoConfTimer } from '../../lib/methods/videoConfTimer';
import { getUserSelector } from '../../selectors/login';
import { ChatsStackParamList } from '../../stacks/types';
Expand All @@ -26,26 +26,6 @@ const JitsiMeetView = (): React.ReactElement => {
const [authModal, setAuthModal] = useState(false);
const [cookiesSet, setCookiesSet] = useState(false);

const setCookies = async () => {
const date = new Date();
date.setDate(date.getDate() + 1);
const expires = date.toISOString();
const domain = serverUrl.replace(/^https?:\/\//, '');
const ck = { domain, version: '1', expires };

await CookieManager.set(serverUrl, {
name: 'rc_uid',
value: user.id,
...ck
});
await CookieManager.set(serverUrl, {
name: 'rc_token',
value: user.token,
...ck
});
setCookiesSet(true);
};

const handleJitsiApp = useCallback(async () => {
const callUrl = url.replace(/^https?:\/\//, '');
try {
Expand Down Expand Up @@ -98,8 +78,33 @@ const JitsiMeetView = (): React.ReactElement => {
}, [handleJitsiApp, onConferenceJoined, videoConf]);

useEffect(() => {
const setCookies = async () => {
const date = new Date();
date.setDate(date.getDate() + 1);
const expires = date.toISOString();
// get rid of the port value if any, since it isn't necessary for cookie domain and causes error
const domain = serverUrl.replace(/^https?:\/\//, '').split(':')[0];
const ck = { domain, version: '1', expires };

try {
await CookieManager.set(serverUrl, {
name: 'rc_uid',
value: user.id,
...ck
});
await CookieManager.set(serverUrl, {
name: 'rc_token',
value: user.token,
...ck
});
setCookiesSet(true);
} catch (error) {
log(error);
}
};

setCookies();
}, []);
}, [serverUrl, user.id, user.token]);

const callUrl = `${url}${url.includes('#config') ? '&' : '#'}config.disableDeepLinking=true`;

Expand Down