Skip to content

Commit

Permalink
Revert "feat(chat): Implement federated logout with custom session te…
Browse files Browse the repository at this point in the history
…rmination flow (#2079)"

This reverts commit 7cc8b0d.

# Conflicts:
#	apps/chat-e2e/src/tests/announcementBanner.test.ts
  • Loading branch information
IlyaBondar committed Jan 8, 2025
1 parent 3bee9b1 commit bfa9201
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 128 deletions.
46 changes: 19 additions & 27 deletions apps/chat-e2e/src/tests/announcementBanner.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Conversation } from '@/chat/types/chat';

import dialTest from '@/src/core/dialFixtures';
import { AccountMenuOptions, ExpectedMessages } from '@/src/testData';
import { expect } from '@playwright/test';
Expand All @@ -7,28 +8,24 @@ dialTest(
'Banner is shown.\n' +
'Banner text contains html link.\n' +
"Banner doesn't appear if to close it",
async (
{
dialHomePage,
conversationData,
dataInjector,
chatBar,
promptBar,
conversations,
banner,
header,
appContainer,
accountSettings,
accountDropdownMenu,
confirmationDialog,
providerLogin,
setTestIds,
},
testInfo,
) => {
async ({
dialHomePage,
conversationData,
dataInjector,
chatBar,
promptBar,
conversations,
banner,
header,
appContainer,
chatMessages,
accountSettings,
accountDropdownMenu,
confirmationDialog,
providerLogin,
setTestIds,
}) => {
setTestIds('EPMRTC-1576', 'EPMRTC-1580', 'EPMRTC-1577');
const username =
process.env.E2E_USERNAME!.split(',')[+process.env.TEST_PARALLEL_INDEX!];
let conversation: Conversation;
let chatBarBounding;
let promptBarBounding;
Expand Down Expand Up @@ -149,12 +146,7 @@ dialTest(
await accountDropdownMenu.selectMenuOption(AccountMenuOptions.logout);
await confirmationDialog.confirm();
await providerLogin.navigateToCredentialsPage();
await providerLogin.authProviderLogin(
testInfo,
username,
process.env.E2E_PASSWORD!,
false,
);
await chatMessages.waitForState({ state: 'attached' });
await expect
.soft(banner.getElementLocator(), ExpectedMessages.bannerIsClosed)
.toBeHidden();
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/ui/actions/providerLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export abstract class ProviderLogin<T extends BasePage & LoginInterface> {
: await this.loginPage.navigateToBaseUrl();
}

public async authProviderLogin(
protected async authProviderLogin(
testInfo: TestInfo,
username: string,
password: string,
Expand Down
8 changes: 4 additions & 4 deletions apps/chat/src/components/Header/User/UserDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/*eslint-disable @next/next/no-img-element*/
import { IconSettings } from '@tabler/icons-react';
import { signIn, useSession } from 'next-auth/react';
import { signIn, signOut, useSession } from 'next-auth/react';
import { useCallback, useState } from 'react';

import { useTranslation } from 'next-i18next';

import { customSignOut } from '@/src/utils/auth/signOut';

import { Translation } from '@/src/types/translation';

import { useAppDispatch } from '@/src/store/hooks';
Expand All @@ -29,7 +27,9 @@ export const UserDesktop = Inversify.register('UserDesktop', () => {
const { data: session } = useSession();
const dispatch = useAppDispatch();
const handleLogout = useCallback(() => {
session ? customSignOut() : signIn('azure-ad', { redirect: true });
session
? signOut({ redirect: true })
: signIn('azure-ad', { redirect: true });
}, [session]);

return (
Expand Down
8 changes: 4 additions & 4 deletions apps/chat/src/components/Header/User/UserMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*eslint-disable @next/next/no-img-element*/
import { IconSettings } from '@tabler/icons-react';
import { signIn, useSession } from 'next-auth/react';
import { signIn, signOut, useSession } from 'next-auth/react';
import { useCallback, useState } from 'react';

import { useTranslation } from 'next-i18next';

import classNames from 'classnames';

import { customSignOut } from '@/src/utils/auth/signOut';

import { Translation } from '@/src/types/translation';

import { useAppDispatch, useAppSelector } from '@/src/store/hooks';
Expand Down Expand Up @@ -76,7 +74,9 @@ const Logout = () => {
useState(false);

const handleLogout = useCallback(() => {
session ? customSignOut() : signIn('azure-ad', { redirect: true });
session
? signOut({ redirect: true })
: signIn('azure-ad', { redirect: true });
}, [session]);
return (
<>
Expand Down
64 changes: 0 additions & 64 deletions apps/chat/src/pages/api/auth/federated-logout.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/chat/src/utils/auth/auth-callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export const callbacks: Partial<
refreshToken: options.account.refresh_token,
providerId: options.account.provider,
userId: options.user.id,
idToken: options.account.id_token,
};
}

Expand Down
27 changes: 0 additions & 27 deletions apps/chat/src/utils/auth/signOut.ts

This file was deleted.

0 comments on commit bfa9201

Please sign in to comment.