Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 327c03c098 | |||
|
|
5e48f5737f |
@@ -5,6 +5,7 @@ using FictionArchive.Service.NovelService.Models.Novels;
|
|||||||
using FictionArchive.Service.NovelService.Models.SourceAdapters;
|
using FictionArchive.Service.NovelService.Models.SourceAdapters;
|
||||||
using FictionArchive.Service.NovelService.Services;
|
using FictionArchive.Service.NovelService.Services;
|
||||||
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
using FictionArchive.Service.NovelService.Services.SourceAdapters;
|
||||||
|
using FictionArchive.Service.Shared.Constants;
|
||||||
using FictionArchive.Service.Shared.Contracts.Events;
|
using FictionArchive.Service.Shared.Contracts.Events;
|
||||||
using HotChocolate.Authorization;
|
using HotChocolate.Authorization;
|
||||||
using HotChocolate.Types;
|
using HotChocolate.Types;
|
||||||
@@ -21,19 +22,8 @@ public class Mutation
|
|||||||
return await service.QueueNovelImport(novelUrl);
|
return await service.QueueNovelImport(novelUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
|
||||||
public async Task<ChapterPullRequested> FetchChapterContents(
|
|
||||||
Guid importId,
|
|
||||||
uint novelId,
|
|
||||||
uint volumeId,
|
|
||||||
uint chapterOrder,
|
|
||||||
NovelUpdateService service)
|
|
||||||
{
|
|
||||||
return await service.QueueChapterPull(importId, novelId, volumeId, chapterOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Error<KeyNotFoundException>]
|
[Error<KeyNotFoundException>]
|
||||||
[Authorize]
|
[Authorize(Roles = [AuthorizationConstants.Roles.Admin])]
|
||||||
public async Task<bool> DeleteNovel(uint novelId, NovelUpdateService service)
|
public async Task<bool> DeleteNovel(uint novelId, NovelUpdateService service)
|
||||||
{
|
{
|
||||||
await service.DeleteNovel(novelId);
|
await service.DeleteNovel(novelId);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { writable, derived } from 'svelte/store';
|
import { writable, derived, get } from 'svelte/store';
|
||||||
import type { User } from 'oidc-client-ts';
|
import type { User } from 'oidc-client-ts';
|
||||||
import { userManager, isOidcConfigured } from './oidcConfig';
|
import { userManager, isOidcConfigured } from './oidcConfig';
|
||||||
|
|
||||||
@@ -8,6 +8,15 @@ export const isLoading = writable(true);
|
|||||||
export const isAuthenticated = derived(user, ($user) => $user !== null);
|
export const isAuthenticated = derived(user, ($user) => $user !== null);
|
||||||
export const isConfigured = isOidcConfigured;
|
export const isConfigured = isOidcConfigured;
|
||||||
|
|
||||||
|
export const userGroups = derived(user, ($user) => {
|
||||||
|
const groups = $user?.profile?.groups;
|
||||||
|
return Array.isArray(groups) ? (groups as string[]) : [];
|
||||||
|
});
|
||||||
|
|
||||||
|
export function hasGroup(groupName: string): boolean {
|
||||||
|
return get(userGroups).includes(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
// Cookie management
|
// Cookie management
|
||||||
function setCookieFromUser(u: User) {
|
function setCookieFromUser(u: User) {
|
||||||
if (!u?.access_token) return;
|
if (!u?.access_token) return;
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { client } from '$lib/graphql/client';
|
import { client } from '$lib/graphql/client';
|
||||||
import { NovelDocument, ImportNovelDocument, DeleteNovelDocument, GetBookmarksDocument } from '$lib/graphql/__generated__/graphql';
|
import { NovelDocument, ImportNovelDocument, DeleteNovelDocument, GetBookmarksDocument } from '$lib/graphql/__generated__/graphql';
|
||||||
import { isAuthenticated } from '$lib/auth/authStore';
|
import { isAuthenticated, hasGroup } from '$lib/auth/authStore';
|
||||||
|
import { Groups } from '$lib/constants/groups';
|
||||||
import { Card, CardContent, CardHeader } from '$lib/components/ui/card';
|
import { Card, CardContent, CardHeader } from '$lib/components/ui/card';
|
||||||
import { Badge } from '$lib/components/ui/badge';
|
import { Badge } from '$lib/components/ui/badge';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
@@ -483,6 +484,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
{#if hasGroup(Groups.Admin)}
|
||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -492,6 +494,7 @@
|
|||||||
<Trash2 class="h-3 w-3" />
|
<Trash2 class="h-3 w-3" />
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
|
{/if}
|
||||||
<AddToReadingListButton novelId={novel.id} />
|
<AddToReadingListButton novelId={novel.id} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if refreshSuccess}
|
{#if refreshSuccess}
|
||||||
|
|||||||
3
fictionarchive-web-astro/src/lib/constants/groups.ts
Normal file
3
fictionarchive-web-astro/src/lib/constants/groups.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const Groups = {
|
||||||
|
Admin: 'admin'
|
||||||
|
} as const;
|
||||||
Reference in New Issue
Block a user