From d54ab3717fe6d7bde5e6e53dc33c723b58203e02 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 11 Jun 2018 13:25:24 +0200 Subject: [PATCH] git for admin only ... --- Yavsc/ApiControllers/{ => IT}/GitRefsApiController.cs | 2 ++ Yavsc/Controllers/{ => IT}/GitController.cs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) rename Yavsc/ApiControllers/{ => IT}/GitRefsApiController.cs (98%) rename Yavsc/Controllers/{ => IT}/GitController.cs (96%) diff --git a/Yavsc/ApiControllers/GitRefsApiController.cs b/Yavsc/ApiControllers/IT/GitRefsApiController.cs similarity index 98% rename from Yavsc/ApiControllers/GitRefsApiController.cs rename to Yavsc/ApiControllers/IT/GitRefsApiController.cs index 925918ae..90816191 100644 --- a/Yavsc/ApiControllers/GitRefsApiController.cs +++ b/Yavsc/ApiControllers/IT/GitRefsApiController.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; using Microsoft.Data.Entity; @@ -11,6 +12,7 @@ namespace Yavsc.Controllers { [Produces("application/json")] [Route("api/GitRefsApi")] + [Authorize("AdministratorOnly")] public class GitRefsApiController : Controller { private ApplicationDbContext _context; diff --git a/Yavsc/Controllers/GitController.cs b/Yavsc/Controllers/IT/GitController.cs similarity index 96% rename from Yavsc/Controllers/GitController.cs rename to Yavsc/Controllers/IT/GitController.cs index b1b804cf..18e0629b 100644 --- a/Yavsc/Controllers/GitController.cs +++ b/Yavsc/Controllers/IT/GitController.cs @@ -1,5 +1,7 @@ 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; @@ -8,6 +10,7 @@ using Yavsc.Server.Models.IT.SourceCode; namespace Yavsc.Controllers { + [Authorize("AdministratorOnly")] public class GitController : Controller { private ApplicationDbContext _context; @@ -44,7 +47,6 @@ namespace Yavsc.Controllers // GET: Git/Create public IActionResult Create() { - ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner"); return View(); } @@ -53,6 +55,7 @@ namespace Yavsc.Controllers [ValidateAntiForgeryToken] public async Task Create(GitRepositoryReference gitRepositoryReference) { + gitRepositoryReference.OwnerId = User.GetUserId(); if (ModelState.IsValid) { _context.GitRepositoryReference.Add(gitRepositoryReference);