Skip to content

Commit 53464e3

Browse files
committed
added authoroty to delete to teachers
1 parent a537acf commit 53464e3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

exercise.wwwapi/Endpoints/UserEndpoints.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,11 @@ public static async Task<IResult> UpdateUser(IRepository<User> userRepository, i
386386
public static async Task<IResult> DeleteUser(IRepository<User> userRepository, int id,
387387
ClaimsPrincipal claimsPrincipal)
388388
{
389+
var userRole = claimsPrincipal.Role();
390+
var authorizedAsTeacher = AuthorizeTeacher(claimsPrincipal);
391+
389392
var userIdClaim = claimsPrincipal.UserRealId();
390-
if (userIdClaim == null || userIdClaim != id)
393+
if (!authorizedAsTeacher && (userIdClaim == null || userIdClaim != id))
391394
{
392395
return Results.Unauthorized();
393396
}

0 commit comments

Comments
 (0)