refacto API prefix + nav.back
This commit is contained in:
parent
bd6ca9d11f
commit
6825f74308
78 changed files with 770 additions and 222 deletions
|
|
@ -10,7 +10,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/blacklist"), Authorize]
|
||||
[Route(Constants.APIPrefix + "/blacklist"), Authorize]
|
||||
public class BlackListApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -50,8 +50,8 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != blackListed.OwnerId)
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(YavscConstants.FrontOfficeGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.FrontOfficeGroupName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (!CheckPermission(blackListed))
|
||||
return BadRequest();
|
||||
|
||||
|
||||
_context.BlackListed.Remove(blackListed);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ using Microsoft.EntityFrameworkCore;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
||||
[Route("api/chat")]
|
||||
[Route(Constants.APIPrefix + "/chat")]
|
||||
public class ChatApiController : Controller
|
||||
{
|
||||
readonly ApplicationDbContext dbContext;
|
||||
readonly UserManager<ApplicationUser> userManager;
|
||||
private readonly IConnexionManager _cxManager;
|
||||
public ChatApiController(ApplicationDbContext dbContext,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IConnexionManager cxManager)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ChatRoomAccessApi")]
|
||||
[Route(Constants.APIPrefix + "/ChatRoomAccessApi")]
|
||||
public class ChatRoomAccessApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -37,7 +37,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
ChatRoomAccess chatRoomAccess = await _context.ChatRoomAccess.SingleAsync(m => m.ChannelName == id);
|
||||
|
||||
|
||||
|
||||
|
||||
if (chatRoomAccess == null)
|
||||
{
|
||||
|
|
@ -46,13 +46,13 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != chatRoomAccess.UserId && uid != chatRoomAccess.Room.OwnerId
|
||||
&& ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
|
||||
&& ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
|
||||
{
|
||||
ModelState.AddModelError("UserId","get refused");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
|
||||
return Ok(chatRoomAccess);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
|
||||
if (uid != room.OwnerId && ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (uid != room.OwnerId && ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access put refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
@ -110,7 +110,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && ! User.IsInMsRole(YavscConstants.AdminGroupName)))
|
||||
if (room == null || (uid != room.OwnerId && ! User.IsInMsRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access post refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
@ -154,7 +154,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && chatRoomAccess.UserId != uid && ! User.IsInMsRole(YavscConstants.AdminGroupName)))
|
||||
if (room == null || (uid != room.OwnerId && chatRoomAccess.UserId != uid && ! User.IsInMsRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("UserId", "access drop refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ChatRoomApi")]
|
||||
[Route(Constants.APIPrefix + "/ChatRoomApi")]
|
||||
public class ChatRoomApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -128,7 +128,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
ChatRoom chatRoom = await _context.ChatRoom.SingleAsync(m => m.Name == id);
|
||||
|
||||
|
||||
|
||||
|
||||
if (chatRoom == null)
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (User.GetUserId() != chatRoom.OwnerId )
|
||||
{
|
||||
if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return BadRequest(new {error = "OwnerId"});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ContactsApi")]
|
||||
[Route(Constants.APIPrefix + "/ContactsApi")]
|
||||
public class ContactsApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue