ColorAuthentication no longer is YesAuthentication
This commit is contained in:
parent
0cdc5ebb20
commit
58cf1cd74c
@ -1,41 +1,43 @@
|
|||||||
|
using API.Authentication.GrantNames;
|
||||||
using API.Authentication.Interfaces;
|
using API.Authentication.Interfaces;
|
||||||
using API.DTO.Base;
|
using API.DTO.Base;
|
||||||
|
using API.Services;
|
||||||
using DAL.Models;
|
using DAL.Models;
|
||||||
|
|
||||||
namespace API.Authentication
|
namespace API.Authentication
|
||||||
{
|
{
|
||||||
public class ColorAuthentication : IColorAuthentication
|
public class ColorAuthentication : IColorAuthentication
|
||||||
{
|
{
|
||||||
|
private readonly GrantService _grantService;
|
||||||
private readonly ILogger<ColorAuthentication> _logger;
|
private readonly ILogger<ColorAuthentication> _logger;
|
||||||
public ColorAuthentication(ILogger<ColorAuthentication> logger)
|
public ColorAuthentication(ILogger<ColorAuthentication> logger, GrantService grantService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_grantService = grantService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool canGetAll(User user)
|
public bool canGetAll(User user)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanGetAll);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public bool canGet(Color model, User user)
|
public bool canGet(Color model, User user)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanGetAny) ||
|
||||||
return true;
|
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanGet).Exists(x => x == model.id);
|
||||||
}
|
}
|
||||||
public bool canAdd(ColorDTO item, User user)
|
public bool canAdd(ColorDTO item, User user)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanAdd);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
public bool canUpdate(Color model, User user)
|
public bool canUpdate(Color model, User user)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanUpdateAny) ||
|
||||||
return true;
|
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanUpdate).Exists(x => x == model.id);
|
||||||
}
|
}
|
||||||
public bool canDelete(Color model, User user)
|
public bool canDelete(Color model, User user)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanDeleteAny) ||
|
||||||
return true;
|
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanDelete).Exists(x => x == model.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user