Settings-Seiten mit Authorize-Attribut versehen

This commit is contained in:
BuildTools 2024-09-04 18:47:12 +02:00
parent e03653de58
commit fde6d87905
3 changed files with 9 additions and 3 deletions

View File

@ -1,9 +1,11 @@
@page "/settings/quizzes/edit" @page "/settings/quizzes/edit"
@page "/settings/quizzes/edit/{id}" @page "/settings/quizzes/edit/{id}"
@using FWLAZ_Web.Data @using FWLAZ_Web.Data
@using Microsoft.AspNetCore.Authorization
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<LocalDbContext> DbFactory; @inject IDbContextFactory<LocalDbContext> DbFactory;
@inject NavigationManager nav; @inject NavigationManager nav;
@attribute [Authorize]
<h3>QuizEdit</h3> <h3>QuizEdit</h3>
<div class="d-flex gap-3"> <div class="d-flex gap-3">

View File

@ -1,9 +1,11 @@
@page "/settings/quizzes/questions/{id}" @page "/settings/quizzes/questions/{id}"
@using FWLAZ_Web.Data @using FWLAZ_Web.Data
@using FWLAZ_Web.Objects @using FWLAZ_Web.Objects
@using Microsoft.AspNetCore.Authorization
@using Microsoft.EntityFrameworkCore; @using Microsoft.EntityFrameworkCore;
@inject IDbContextFactory<LocalDbContext> DbFactory; @inject IDbContextFactory<LocalDbContext> DbFactory;
@inject NavigationManager nav; @inject NavigationManager nav;
@attribute [Authorize]
<h1>Questions for '@SelectedItem.Name'</h1> <h1>Questions for '@SelectedItem.Name'</h1>

View File

@ -1,7 +1,9 @@
@page "/settings/quizzes" @page "/settings/quizzes"
@using FWLAZ_Web.Data @using FWLAZ_Web.Data
@using Microsoft.AspNetCore.Authorization
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<LocalDbContext> DbFactory ; @inject IDbContextFactory<LocalDbContext> DbFactory ;
@attribute [Authorize]
<h3>Quizzes</h3> <h3>Quizzes</h3>
@ -25,7 +27,7 @@
</table> </table>
</div> </div>
<ModalComponent @ref="modal"> <ModalDialog @ref="modal">
<Title>Löschen bestätigen</Title> <Title>Löschen bestätigen</Title>
<Body> <Body>
Willst du das Quiz wirklich löschen? Willst du das Quiz wirklich löschen?
@ -34,11 +36,11 @@
<button class="btn btn-danger" @onclick="DeleteItem">Ja</button> <button class="btn btn-danger" @onclick="DeleteItem">Ja</button>
<button class="btn btn-primary" @onclick="CloseDialog">Nein</button> <button class="btn btn-primary" @onclick="CloseDialog">Nein</button>
</Footer> </Footer>
</ModalComponent> </ModalDialog>
@code { @code {
private LocalDbContext? DataContext; private LocalDbContext? DataContext;
private ModalComponent modal = null!; private ModalDialog modal = null!;
private Quiz? SelectedItem; private Quiz? SelectedItem;
private List<Quiz> QuizList { get; set; } = new(); private List<Quiz> QuizList { get; set; } = new();