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.DTO.Base;
|
||||
using API.Services;
|
||||
using DAL.Models;
|
||||
|
||||
namespace API.Authentication
|
||||
{
|
||||
public class ColorAuthentication : IColorAuthentication
|
||||
{
|
||||
private readonly GrantService _grantService;
|
||||
private readonly ILogger<ColorAuthentication> _logger;
|
||||
public ColorAuthentication(ILogger<ColorAuthentication> logger)
|
||||
public ColorAuthentication(ILogger<ColorAuthentication> logger, GrantService grantService)
|
||||
{
|
||||
_logger = logger;
|
||||
_grantService = grantService;
|
||||
}
|
||||
|
||||
public bool canGetAll(User user)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
||||
return true;
|
||||
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanGetAll);
|
||||
}
|
||||
public bool canGet(Color model, User user)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
||||
return true;
|
||||
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanGetAny) ||
|
||||
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanGet).Exists(x => x == model.id);
|
||||
}
|
||||
public bool canAdd(ColorDTO item, User user)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
||||
return true;
|
||||
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanAdd);
|
||||
}
|
||||
public bool canUpdate(Color model, User user)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
||||
return true;
|
||||
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanUpdateAny) ||
|
||||
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanUpdate).Exists(x => x == model.id);
|
||||
}
|
||||
public bool canDelete(Color model, User user)
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, "Yes Authentication being used.");
|
||||
return true;
|
||||
return _grantService.hasGrant(user.permissionId, ColorGrantNames.CanDeleteAny) ||
|
||||
_grantService.getULongValues(user.permissionId, ColorGrantNames.CanDelete).Exists(x => x == model.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user