FIXME SR is private
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
@ -31,13 +30,13 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(musicianSettings);
|
||||
@ -46,7 +45,7 @@ namespace Yavsc.Controllers
|
||||
// GET: Instrumentation/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
@ -61,7 +60,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Instrumentation model)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
@ -77,17 +76,17 @@ namespace Yavsc.Controllers
|
||||
// GET: Instrumentation/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
@ -97,7 +96,7 @@ namespace Yavsc.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
@ -115,15 +114,15 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
@ -136,7 +135,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
Reference in New Issue
Block a user