* Getting new netcore PublicAccessChecker in place * Adds full test coverage for PublicAccessChecker * remove PublicAccessComposer * adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller * Implements the required methods on IMemberManager, removes old migrated code * Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops * adds note * adds note * Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling. * Changes name to IUmbracoEndpointBuilder * adds note * Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect * fixing build * Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware. * adds note * removes unused filter, fixes build * fixes WebPath and tests * Looks up entities in one query * remove usings * Fix test, remove stylesheet * Set status code before we write to response to avoid error * Ensures that users and members are validated when logging in. Shares more code between users and members. * Fixes RepositoryCacheKeys to ensure the keys are normalized * oops didn't mean to commit this * Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy * bah, far out this keeps getting recommitted. sorry Co-authored-by: Bjarke Berg <mail@bergmania.dk>
101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.Logging;
|
|
using NPoco;
|
|
using Umbraco.Cms.Core.Cache;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Persistence.Querying;
|
|
using Umbraco.Cms.Core.Persistence.Repositories;
|
|
using Umbraco.Cms.Core.Scoping;
|
|
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
|
|
using Umbraco.Cms.Infrastructure.Persistence.Factories;
|
|
using Umbraco.Cms.Infrastructure.Persistence.Querying;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
|
{
|
|
/// <summary>
|
|
/// Represents the NPoco implementation of <see cref="IConsentRepository"/>.
|
|
/// </summary>
|
|
internal class ConsentRepository : EntityRepositoryBase<int, IConsent>, IConsentRepository
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ConsentRepository"/> class.
|
|
/// </summary>
|
|
public ConsentRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger<ConsentRepository> logger)
|
|
: base(scopeAccessor, cache, logger)
|
|
{ }
|
|
|
|
/// <inheritdoc />
|
|
protected override IConsent PerformGet(int id)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override IEnumerable<IConsent> PerformGetAll(params int[] ids)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override IEnumerable<IConsent> PerformGetByQuery(IQuery<IConsent> query)
|
|
{
|
|
var sqlClause = Sql().Select<ConsentDto>().From<ConsentDto>();
|
|
var translator = new SqlTranslator<IConsent>(sqlClause, query);
|
|
var sql = translator.Translate().OrderByDescending<ConsentDto>(x => x.CreateDate);
|
|
return ConsentFactory.BuildEntities(Database.Fetch<ConsentDto>(sql));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override string GetBaseWhereClause()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override IEnumerable<string> GetDeleteClauses()
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void PersistNewItem(IConsent entity)
|
|
{
|
|
entity.AddingEntity();
|
|
|
|
var dto = ConsentFactory.BuildDto(entity);
|
|
Database.Insert(dto);
|
|
entity.Id = dto.Id;
|
|
entity.ResetDirtyProperties();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void PersistUpdatedItem(IConsent entity)
|
|
{
|
|
entity.UpdatingEntity();
|
|
|
|
var dto = ConsentFactory.BuildDto(entity);
|
|
Database.Update(dto);
|
|
entity.ResetDirtyProperties();
|
|
|
|
IsolatedCache.Clear(RepositoryCacheKeys.GetKey<IConsent, int>(entity.Id));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void ClearCurrent(string source, string context, string action)
|
|
{
|
|
var sql = Sql()
|
|
.Update<ConsentDto>(u => u.Set(x => x.Current, false))
|
|
.Where<ConsentDto>(x => x.Source == source && x.Context == context && x.Action == action && x.Current);
|
|
Database.Execute(sql);
|
|
}
|
|
}
|
|
}
|