REORG+histo
This commit is contained in:
parent
459f8ea422
commit
6dd76ac1a5
28 changed files with 948 additions and 159 deletions
|
|
@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using isnd.Data;
|
||||
using isnd.ViewModels;
|
||||
|
||||
using isnd.Helpers;
|
||||
namespace isnd
|
||||
{
|
||||
[AllowAnonymous]
|
||||
|
|
@ -78,16 +78,11 @@ namespace isnd
|
|||
return NotFound();
|
||||
}
|
||||
|
||||
if (!IsOwner(packageVersion)) return Unauthorized();
|
||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
||||
|
||||
return View(packageVersion);
|
||||
}
|
||||
|
||||
bool IsOwner(PackageVersion v)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return v.Package.OwnerId == userId;
|
||||
}
|
||||
|
||||
// POST: PackageVersion/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
|
|
@ -97,7 +92,7 @@ namespace isnd
|
|||
var packageVersion = await _context.PackageVersions.Include(p => p.Package)
|
||||
.FirstOrDefaultAsync(m => m.PackageId == PackageId && m.FullString == FullString);
|
||||
if (packageVersion == null) return NotFound();
|
||||
if (!IsOwner(packageVersion)) return Unauthorized();
|
||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
||||
|
||||
_context.PackageVersions.Remove(packageVersion);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue