public async Task <bool> IsPermitted(int userId, params RoleType[] roleTypes) { if (Configuration.IsDev(userId)) { return(true); } var query = RolesServiceUtils.BuildIsPermittedQuery(userId, roleTypes); var result = await database.SelectQueryFirst <IsPermittedResult>(query) ?? throw new DatabaseException(); return(result.IsPermitted); }
public async Task <bool> IsPermitted(User user, params RoleType[] roleTypes) { if (user == null) { throw new EntityNotFoundException("User not found"); } if (Configuration.IsDev(user.Id)) { return(true); } var query = RolesServiceUtils.BuildIsPermittedQuery(user.Id, roleTypes); var result = await database.SelectQueryFirst <IsPermittedResult>(query) ?? throw new DatabaseException(); return(result.IsPermitted); }