feat(backend/auth): add authorization to Lessons endpoints
- Add RequireAuthorization() to POST, PUT, DELETE endpoints - Add Microsoft.AspNetCore.Authorization using - Lessons now require JWT token for create, update, delete Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
df374dbd26
commit
3c33253cba
1 changed files with 4 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using GermanApp.Application.DTOs;
|
using GermanApp.Application.DTOs;
|
||||||
using GermanApp.Application.UseCases.Commands;
|
using GermanApp.Application.UseCases.Commands;
|
||||||
using GermanApp.Domain.Interfaces;
|
using GermanApp.Domain.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace GermanApp.Presentation.Endpoints;
|
namespace GermanApp.Presentation.Endpoints;
|
||||||
|
|
@ -90,6 +91,7 @@ public static class LessonsEndpoints
|
||||||
var result = await handler.Handle(command, cancellationToken);
|
var result = await handler.Handle(command, cancellationToken);
|
||||||
return Results.Created($"/api/lessons/{result.Id}", result);
|
return Results.Created($"/api/lessons/{result.Id}", result);
|
||||||
})
|
})
|
||||||
|
.RequireAuthorization()
|
||||||
.WithName("CreateLesson")
|
.WithName("CreateLesson")
|
||||||
.WithOpenApi(operation => new(operation)
|
.WithOpenApi(operation => new(operation)
|
||||||
{
|
{
|
||||||
|
|
@ -113,6 +115,7 @@ public static class LessonsEndpoints
|
||||||
|
|
||||||
return Results.Ok(existingLesson.ToDto());
|
return Results.Ok(existingLesson.ToDto());
|
||||||
})
|
})
|
||||||
|
.RequireAuthorization()
|
||||||
.WithName("UpdateLesson")
|
.WithName("UpdateLesson")
|
||||||
.WithOpenApi(operation => new(operation)
|
.WithOpenApi(operation => new(operation)
|
||||||
{
|
{
|
||||||
|
|
@ -130,6 +133,7 @@ public static class LessonsEndpoints
|
||||||
await repository.DeleteAsync(lesson);
|
await repository.DeleteAsync(lesson);
|
||||||
return Results.NoContent();
|
return Results.NoContent();
|
||||||
})
|
})
|
||||||
|
.RequireAuthorization()
|
||||||
.WithName("DeleteLesson")
|
.WithName("DeleteLesson")
|
||||||
.WithOpenApi(operation => new(operation)
|
.WithOpenApi(operation => new(operation)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue