git for admin only ...
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
@ -11,6 +12,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Route("api/GitRefsApi")]
|
[Route("api/GitRefsApi")]
|
||||||
|
[Authorize("AdministratorOnly")]
|
||||||
public class GitRefsApiController : Controller
|
public class GitRefsApiController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private ApplicationDbContext _context;
|
@ -1,5 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
@ -8,6 +10,7 @@ using Yavsc.Server.Models.IT.SourceCode;
|
|||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
[Authorize("AdministratorOnly")]
|
||||||
public class GitController : Controller
|
public class GitController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private ApplicationDbContext _context;
|
||||||
@ -44,7 +47,6 @@ namespace Yavsc.Controllers
|
|||||||
// GET: Git/Create
|
// GET: Git/Create
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner");
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ namespace Yavsc.Controllers
|
|||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Create(GitRepositoryReference gitRepositoryReference)
|
public async Task<IActionResult> Create(GitRepositoryReference gitRepositoryReference)
|
||||||
{
|
{
|
||||||
|
gitRepositoryReference.OwnerId = User.GetUserId();
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
_context.GitRepositoryReference.Add(gitRepositoryReference);
|
_context.GitRepositoryReference.Add(gitRepositoryReference);
|
Reference in New Issue
Block a user