Skip to content

Commit

Permalink
feat: disable duplicate idir feature
Browse files Browse the repository at this point in the history
  • Loading branch information
NithinKuruba committed Sep 12, 2023
1 parent 816a5b8 commit 262c986
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/controllers/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export async function getAllowedRealms(session: any) {
}

export async function getAllowedRealmNames(session: any) {
const username = session?.idir_username || '';
const roles = session?.client_roles || [];
const username = session?.user?.idir_username || '';
const roles = session?.user?.client_roles || [];
const isAdmin = roles.includes('sso-admin');
let result: any = null;

Expand Down
5 changes: 3 additions & 2 deletions app/page-partials/my-dashboard/RealmLeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ function RealmLeftPanel({ realms, onEditClick, onCancel }: Props) {
<a className={`nav-link ${tab === 'dashboard' ? 'active' : ''}`} onClick={() => setTab('dashboard')}>
My Dashboard
</a>
<a
{/* Disabling this feature as part of migration to gold */}
{/* <a
className={`nav-link ${tab === 'duplicate' ? 'active' : ''}`}
onClick={() => {
setTab('duplicate');
onCancel();
}}
>
Duplicate Users
</a>
</a> */}
</Tabs>
{tab === 'dashboard' ? <RealmTable realms={realms} onEditClick={onEditClick} /> : <DuplicateIDIR />}
</>
Expand Down
4 changes: 2 additions & 2 deletions app/pages/api/surveys/1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
const session = await validateRequest(req, res);
if (!session) return res.status(401).json({ success: false, error: 'jwt expired' });

const username = session?.idir_username || '';
const roles = session?.client_roles || [];
const username = session?.user?.idir_username || '';
const roles = session?.user?.client_roles || [];
const isAdmin = roles.includes('sso-admin');

if (req.method === 'GET') {
Expand Down
10 changes: 6 additions & 4 deletions app/pages/api/users/idir.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { validateRequest } from 'utils/jwt';
import KeycloakCore from 'utils/keycloak-core';
import { getAllowedRealms, getAllowedRealmNames } from 'controllers/realm';
import { getAllowedRealmNames } from 'controllers/realm';
import { getServerSession } from 'next-auth/next';
import { authOptions } from '../auth/[...nextauth]';

interface ErrorData {
success: boolean;
Expand All @@ -12,8 +13,9 @@ type Data = ErrorData | string | any;

export default async function handler(req: NextApiRequest, res: NextApiResponse<Data>) {
try {
const session = await validateRequest(req, res);
if (!session) return res.status(401).json({ success: false, error: 'jwt expired' });
const session: any = await getServerSession(req, res, authOptions);

if (!session) return res.status(401).json({ success: false, error: 'unauthorized' });

const { search, env } = req.query;
const searchParam = String(search);
Expand Down

0 comments on commit 262c986

Please sign in to comment.