D
D
dgash22012021-07-29 18:36:08
ASP.NET
dgash2201, 2021-07-29 18:36:08

How in ASP.NET Core Web API to implement a method for deleting a user by Id so that one user cannot delete another?

Hello! I want to implement a method to delete a user by Id. But after all, a user can enter the Id of another user and delete his account. How can you protect yourself from this? To allow the user to delete only their own account.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-07-29
@firedragon

https://docs.microsoft.com/ru-ru/dotnet/api/micros...
To the delete controller.
Both of these methods are closed with this attribute
GET /api/account/delete issues a page
POST /api/account/delete deletes the user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question