Skip to content

Commit aa96491

Browse files
committed
Fix #33 #35
1 parent eac76ab commit aa96491

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

Backend/SorobanSecurityPortalApi/Controllers/FileController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task<IActionResult> List(string containerGuid)
3333
return Ok(result);
3434
}
3535

36-
[RoleAuthorize(Role.Admin, Role.Moderator)]
36+
[RoleAuthorize(Role.Admin)]
3737
[HttpDelete("api/v1/file/{containerGuid}/{fileName}")]
3838
public async Task<IActionResult> Remove(string containerGuid, string fileName)
3939
{

Backend/SorobanSecurityPortalApi/Controllers/ReportsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public async Task<IActionResult> Reject(int reportId)
151151
throw new InvalidOperationException("Unexpected result type");
152152
}
153153

154-
[RoleAuthorize(Role.Admin, Role.Moderator)]
154+
[RoleAuthorize(Role.Admin)]
155155
[HttpDelete("{reportId}")]
156156
public async Task<IActionResult> Remove(int reportId)
157157
{

Backend/SorobanSecurityPortalApi/Controllers/VulnerabilitiesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public async Task<IActionResult> Reject(int vulnerabilityId)
118118
throw new InvalidOperationException("Unexpected result type");
119119
}
120120

121-
[RoleAuthorize(Role.Admin, Role.Moderator)]
121+
[RoleAuthorize(Role.Admin)]
122122
[HttpDelete("{vulnerabilityId}")]
123123
public async Task<IActionResult> Remove(int vulnerabilityId)
124124
{

Backend/SorobanSecurityPortalApi/Models/ViewModels/FileViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public class FileViewModel
88
public string Type { get; set; } = "";
99
public byte[]? BinFile { get; set; } = null;
1010
public DateTime Date { get; set; }
11-
public string CreatedBy { get; set; } = "";
11+
public int CreatedBy { get; set; }
1212
}
1313
}

UI/src/features/pages/admin/left-menu/admin-left-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const AdminLeftMenu: FC = () => {
8383
label: 'Tags',
8484
icon: <FormatListBulletedIcon />,
8585
path: 'admin/categories',
86-
visible: isAdmin(auth),
86+
visible: isAdminOrModerator(auth),
8787
},
8888
];
8989

UI/src/features/pages/admin/tag/list-view/list-tags.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ import { ConfirmDialog } from '../../admin-main-window/confirm-dialog.tsx';
2222
import { CustomToolbar } from '../../../../components/custom-toolbar.tsx';
2323
import { useNavigate } from 'react-router-dom';
2424
import { defaultUiSettings } from '../../../../../api/soroban-security-portal/models/ui-settings.ts';
25+
import { AuthContextProps, useAuth } from 'react-oidc-context';
26+
import { Role } from '../../../../../api/soroban-security-portal/models/role.ts';
2527

2628
export const ListCategories: FC = () => {
29+
const auth = useAuth();
2730
const navigate = useNavigate();
28-
31+
32+
const isAdmin = (auth: AuthContextProps) => auth.user?.profile.role === Role.Admin;
33+
2934
const currentPageState: CurrentPageState = {
3035
pageName: 'Tags',
3136
pageCode: 'categories',
@@ -41,21 +46,27 @@ export const ListCategories: FC = () => {
4146
setTagIdToRemove(0);
4247
};
4348

44-
const columnsData: GridColDef[] = [
45-
{
46-
field: 'actions',
47-
headerName: 'Actions',
48-
width: 140,
49-
sortable: false,
50-
filterable: false,
51-
renderCell: (params: GridRenderCellParams<TagItem>) => (
52-
<Tooltip title="Remove Tag">
53-
<IconButton onClick={() => setTagIdToRemove(params.row.id)}>
54-
<ClearIcon sx={{ color: 'red' }} />
55-
</IconButton>
56-
</Tooltip>
57-
),
58-
} as GridColDef,
49+
let columnsData: GridColDef[] = [];
50+
if (isAdmin(auth)) {
51+
columnsData.push(
52+
{
53+
field: 'actions',
54+
headerName: 'Actions',
55+
width: 140,
56+
sortable: false,
57+
filterable: false,
58+
renderCell: (params: GridRenderCellParams<TagItem>) => (
59+
(<Tooltip title="Remove Tag">
60+
<IconButton onClick={() => setTagIdToRemove(params.row.id)}>
61+
<ClearIcon sx={{ color: 'red' }} />
62+
</IconButton>
63+
</Tooltip>)
64+
),
65+
} as GridColDef
66+
)
67+
}
68+
69+
columnsData.push(
5970
{
6071
field: 'name',
6172
headerName: 'Tag',
@@ -99,7 +110,7 @@ export const ListCategories: FC = () => {
99110
headerName: 'Created By',
100111
width: 250,
101112
} as GridColDef,
102-
];
113+
);
103114

104115
return (
105116
<div style={defaultUiSettings.listAreaStyle}>

0 commit comments

Comments
 (0)