This commit is contained in:
2025-05-11 00:09:36 +08:00
parent ea926fe7d2
commit ef9227cc01
15 changed files with 243 additions and 19 deletions

View File

@@ -41,8 +41,23 @@
throw new ArticleNotExistsException(request.Id);
}
var identityUser = await _db.Users.FindAsync(_identity.Id);
if (identityUser == null)
{
throw new UserNotExistsException(_identity.Id);
}
if (!string.IsNullOrEmpty(request.Slug) &&
if (!identityUser.IsSystemUser())
{
if (article.UserId != identityUser.Id)
{
throw new AccessDeniedException();
}
}
if (!string.IsNullOrEmpty(request.Slug) &&
article.IsSlugDifferent(request.Slug) &&
await _articleService.IsSlugInUse(request.Slug))
{

View File

@@ -34,6 +34,22 @@
{
throw new ArticleNotExistsException(request.Id);
}
var identityUser = await _db.Users.FindAsync(_identity.Id);
if (identityUser == null)
{
throw new UserNotExistsException(_identity.Id);
}
if (!identityUser.IsSystemUser())
{
if (article.UserId != identityUser.Id)
{
throw new AccessDeniedException();
}
}
article.UpdateDraft(request.Title, request.Content, request.Summary, request.Tags, request.Slug, request.CoverUrl, authorObject, categoryObject);
_db.Articles.Update(article);