Skip to content

Commit e364dd1

Browse files
committed
MMI-3262 Fix user access (bcgov#2458)
1 parent 2a1a7a8 commit e364dd1

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

app/subscriber/src/features/search-page/components/advanced-search/components/sections/MediaTypeSection.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { useContent, useLookupOptions } from 'store/hooks';
2+
import { useApp, useContent, useLookupOptions } from 'store/hooks';
33
import { Button, ButtonVariant, Checkbox, FieldSize, Row, Select, Show } from 'tno-core';
44

55
import { IFilterDisplayProps } from './IFilterDisplayProps';
@@ -12,6 +12,7 @@ export const MediaTypeSection: React.FC<IFilterDisplayProps> = ({ displayFilters
1212
},
1313
{ storeSearchFilter: storeFilter },
1414
] = useContent();
15+
const [{ userInfo }] = useApp();
1516
const [{ mediaTypeOptions }] = useLookupOptions();
1617

1718
return (
@@ -35,24 +36,26 @@ export const MediaTypeSection: React.FC<IFilterDisplayProps> = ({ displayFilters
3536
Deselect All
3637
</Button>
3738
</div>
38-
{mediaTypeOptions.map((item, index) => (
39-
<div key={`chk-media-type-${index}`} className="chk-box-container chk-media-type">
40-
<Checkbox
41-
id={`chk-media-type-${index}`}
42-
label={item.label}
43-
checked={filter.mediaTypeIds?.includes(+item.value!)}
44-
value={item.value}
45-
onChange={(e) => {
46-
storeFilter({
47-
...filter,
48-
mediaTypeIds: e.target.checked
49-
? [...(filter.mediaTypeIds ?? []), +e.target.value] // add it
50-
: filter.mediaTypeIds?.filter((i) => i !== +e.target.value), // remove it
51-
});
52-
}}
53-
/>
54-
</div>
55-
))}
39+
{mediaTypeOptions
40+
.filter((mt) => !userInfo?.mediaTypes.includes(+mt.value!))
41+
.map((item, index) => (
42+
<div key={`chk-media-type-${index}`} className="chk-box-container chk-media-type">
43+
<Checkbox
44+
id={`chk-media-type-${index}`}
45+
label={item.label}
46+
checked={filter.mediaTypeIds?.includes(+item.value!)}
47+
value={item.value}
48+
onChange={(e) => {
49+
storeFilter({
50+
...filter,
51+
mediaTypeIds: e.target.checked
52+
? [...(filter.mediaTypeIds ?? []), +e.target.value] // add it
53+
: filter.mediaTypeIds?.filter((i) => i !== +e.target.value), // remove it
54+
});
55+
}}
56+
/>
57+
</div>
58+
))}
5659
</div>
5760
</Show>
5861
<Show visible={displayFiltersAsDropdown}>

libs/net/dal/Services/UserService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ public IPaged<User> Find(UserFilter filter)
128128
public User? FindByUsername(string username)
129129
{
130130
return this.Context.Users
131-
.Where(u => u.Username.ToLower() == username.ToLower()).FirstOrDefault();
131+
.Include(u => u.MediaTypes)
132+
.Include(u => u.Sources)
133+
.Where(u => u.Username.ToLower() == username.ToLower())
134+
.FirstOrDefault();
132135
}
133136

134137
public IEnumerable<User> FindByEmail(string email)

0 commit comments

Comments
 (0)