From db5d05d6416b5f6696300336eb09ad31b779abf0 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 19 Sep 2022 16:37:24 +0200 Subject: [PATCH] Revert files that shouldn't change back in v11 --- .github/workflows/codeql-analysis.yml | 3 +- build/azure-pipelines.yml | 113 +++++++------ src/Directory.Build.props | 15 +- src/JsonSchema/JsonSchema.csproj | 2 +- .../ManagementApiComposer.cs | 3 +- .../Umbraco.Cms.ManagementApi.csproj | 2 +- .../Umbraco.Cms.Persistence.SqlServer.csproj | 2 +- .../Umbraco.Cms.Persistence.Sqlite.csproj | 3 +- .../Umbraco.Cms.StaticAssets.csproj | 2 +- src/Umbraco.Cms/Umbraco.Cms.csproj | 2 +- src/Umbraco.Core/Composing/IUserComposer.cs | 9 -- .../ConfigureConnectionStrings.cs | 7 +- .../Models/RequestHandlerSettings.cs | 61 ++++--- .../Validation/ContentSettingsValidator.cs | 2 +- .../Validation/GlobalSettingsValidator.cs | 2 +- .../HealthChecksSettingsValidator.cs | 2 +- .../RequestHandlerSettingsValidator.cs | 2 +- .../Validation/UnattendedSettingsValidator.cs | 4 +- src/Umbraco.Core/Constants-Conventions.cs | 62 ------- .../ServiceCollectionExtensions.cs | 11 +- .../UmbracoBuilder.CollectionBuilders.cs | 6 +- .../UmbracoBuilder.Collections.cs | 8 - .../UmbracoBuilder.Configuration.cs | 2 - .../DependencyInjection/UmbracoBuilder.cs | 1 - src/Umbraco.Core/Extensions/EnumExtensions.cs | 53 +++--- .../RequestHandlerSettingsExtension.cs | 40 ++--- .../Checks/Security/BaseHttpHeaderCheck.cs | 12 -- .../Hosting/IHostingEnvironment.cs | 2 +- src/Umbraco.Core/IO/ViewHelper.cs | 20 +-- .../InstallSteps/TelemetryIdentifierStep.cs | 19 +-- .../Media/EmbedProviders/DailyMotion.cs | 2 +- .../Media/EmbedProviders/EmbedProviderBase.cs | 2 +- .../Media/EmbedProviders/Flickr.cs | 2 +- .../Media/EmbedProviders/GettyImages.cs | 2 +- .../Media/EmbedProviders/Giphy.cs | 2 +- src/Umbraco.Core/Media/EmbedProviders/Hulu.cs | 2 +- .../Media/EmbedProviders/Issuu.cs | 2 +- .../Media/EmbedProviders/Kickstarter.cs | 2 +- .../Media/EmbedProviders/Slideshare.cs | 2 +- .../Media/EmbedProviders/SoundCloud.cs | 2 +- src/Umbraco.Core/Media/EmbedProviders/Ted.cs | 2 +- .../Media/EmbedProviders/Twitter.cs | 2 +- .../Media/EmbedProviders/Vimeo.cs | 2 +- .../Media/EmbedProviders/Youtube.cs | 2 +- .../Models/ChangingPasswordModel.cs | 2 +- .../UserGroupPermissionsSave.cs | 11 +- src/Umbraco.Core/Models/ContentType.cs | 2 +- src/Umbraco.Core/Models/IContentType.cs | 19 +-- src/Umbraco.Core/Models/Language.cs | 22 +-- .../Mapping/ContentTypeMapDefinition.cs | 153 +++++++----------- .../Models/Mapping/DictionaryMapDefinition.cs | 9 +- .../Mapping/MemberTabsAndPropertiesMapper.cs | 3 +- .../PublishedContent/PublishedContentType.cs | 24 --- src/Umbraco.Core/Models/RelationType.cs | 11 +- src/Umbraco.Core/Models/SendCodeViewModel.cs | 6 +- src/Umbraco.Core/Models/SetPasswordModel.cs | 6 +- src/Umbraco.Core/Models/UnLinkLoginModel.cs | 6 +- ...icationComponentsInstallingNotification.cs | 27 ---- ...oApplicationMainDomAcquiredNotification.cs | 23 --- .../UmbracoApplicationStartingNotification.cs | 37 ++--- .../UmbracoApplicationStoppingNotification.cs | 27 ++-- .../Repositories/IExternalLoginRepository.cs | 26 --- .../Repositories/IMacroRepository.cs | 7 +- .../Repositories/IMacroWithAliasRepository.cs | 11 -- .../Repositories/IMemberRepository.cs | 16 -- .../Repositories/IUserRepository.cs | 10 +- .../PropertyValueConverterBase.cs | 2 +- .../Routing/DefaultUrlProvider.cs | 45 ++---- .../Services/EntityXmlSerializer.cs | 2 +- .../Services/ExternalLoginService.cs | 33 +--- .../Services/IExternalLoginService.cs | 63 -------- src/Umbraco.Core/Services/IMacroService.cs | 9 +- .../Services/IMacroWithAliasService.cs | 14 -- .../Services/IMembershipMemberService.cs | 14 -- .../Services/ITwoFactorLoginService.cs | 12 +- .../Services/LocalizedTextService.cs | 31 ++-- src/Umbraco.Core/Services/MacroService.cs | 8 +- src/Umbraco.Core/Services/MemberService.cs | 6 +- src/Umbraco.Core/Services/ServiceContext.cs | 10 +- .../Services/TwoFactorLoginService.cs | 19 +-- src/Umbraco.Core/Services/UserService.cs | 7 +- src/Umbraco.Core/Umbraco.Core.csproj | 13 +- src/Umbraco.Core/Web/IRequestAccessor.cs | 4 +- .../WebAssets/IRuntimeMinifier.cs | 50 ++---- .../ConfigureIndexOptions.cs | 2 +- .../Umbraco.Examine.Lucene.csproj | 2 +- .../Configuration/JsonConfigManipulator.cs | 9 +- .../UmbracoBuilder.Repositories.cs | 3 +- .../RecurringHostedServiceBase.cs | 7 - .../HostedServices/ReportSiteTask.cs | 20 +-- .../Logging/Viewer/ILogViewer.cs | 9 +- .../Viewer/SerilogLogViewerSourceBase.cs | 21 +-- .../Install/DatabaseSchemaCreator.cs | 41 ++--- .../Install/DatabaseSchemaCreatorFactory.cs | 39 ++--- .../Upgrade/V_8_0_0/AddTypedLabels.cs | 14 +- .../AutomaticPackageMigrationPlan.cs | 6 +- .../Packaging/PackageDataInstallation.cs | 4 +- .../Packaging/PackageMigrationBase.cs | 45 ++---- .../Implement/ContentTypeRepository.cs | 2 +- .../Implement/ExternalLoginRepository.cs | 15 +- .../Repositories/Implement/MacroRepository.cs | 2 +- .../Implement/MemberRepository.cs | 7 - .../Runtime/CoreRuntime.cs | 14 +- .../BackOfficeClaimsPrincipalFactory.cs | 4 +- .../Security/BackOfficeErrorDescriber.cs | 4 +- .../Security/BackOfficeUserStore.cs | 100 +++++------- .../Security/ClaimsIdentityExtensions.cs | 4 +- .../Security/IUmbracoUserManager.cs | 28 ++-- .../Security/MemberRoleStore.cs | 47 +++--- .../Security/MemberUserStore.cs | 109 ++++++------- .../Security/NoOpLookupNormalizer.cs | 4 +- .../Security/UmbracoErrorDescriberBase.cs | 4 +- .../Security/UmbracoIdentityRole.cs | 14 +- .../Security/UmbracoIdentityUser.cs | 6 +- .../Security/UmbracoUserManager.cs | 14 +- .../Security/UmbracoUserStore.cs | 14 +- .../Templates/HtmlMacroParameterParser.cs | 2 +- .../Umbraco.Infrastructure.csproj | 7 +- .../Umbraco.New.Cms.Core.csproj | 2 +- .../Umbraco.New.Cms.Infrastructure.csproj | 2 +- .../Installer/SignInUserStep.cs | 8 +- .../Umbraco.New.Cms.Web.Common.csproj | 2 +- .../ContentNodeKit.cs | 18 +-- .../DataSource/ContentData.cs | 97 ++--------- .../Umbraco.PublishedCache.NuCache.csproj | 2 +- .../Controllers/AuthenticationController.cs | 35 ++-- .../Controllers/BackOfficeController.cs | 7 +- .../Controllers/BackOfficeServerVariables.cs | 4 +- .../Controllers/CurrentUserController.cs | 73 +++------ .../Controllers/EntityController.cs | 40 ----- .../Controllers/HelpController.cs | 6 - .../Controllers/LanguageController.cs | 22 +-- .../Controllers/LogViewerController.cs | 10 -- .../Controllers/MediaController.cs | 31 ---- .../Controllers/MemberController.cs | 10 +- .../Controllers/MemberTypeController.cs | 11 -- .../Controllers/TemplateController.cs | 25 +-- .../Controllers/TwoFactorLoginController.cs | 20 +-- .../Controllers/UsersController.cs | 16 +- .../UmbracoBuilder.LocalizedText.cs | 4 +- ...CreateUnattendedUserNotificationHandler.cs | 2 +- .../Install/InstallApiController.cs | 8 +- ...igureGlobalOptionsForKeepAliveMiddlware.cs | 4 +- .../BackOfficeAuthenticationBuilder.cs | 4 +- .../Security/BackOfficeSessionIdValidator.cs | 7 +- .../Security/BackOfficeSignInManager.cs | 6 +- .../ConfigureBackOfficeCookieOptions.cs | 2 +- .../Security/PasswordChanger.cs | 4 +- .../Services/IconService.cs | 2 +- .../MemberTypeAndGroupTreeControllerBase.cs | 15 -- .../Umbraco.Web.BackOffice.csproj | 2 +- .../AspNetCoreHostingEnvironment.cs | 2 +- .../AspNetCore/AspNetCoreRequestAccessor.cs | 4 +- .../AspNetCore/OptionsMonitorAdapter.cs | 2 +- .../Extensions/FormCollectionExtensions.cs | 2 +- .../FriendlyImageCropperTemplateExtensions.cs | 8 - .../Extensions/HttpContextExtensions.cs | 4 +- .../Extensions/TypeExtensions.cs | 10 ++ .../Middleware/UmbracoRequestMiddleware.cs | 35 ---- .../Mvc/UmbracoMvcConfigureOptions.cs | 3 + .../Routing/RoutableDocumentFilter.cs | 2 +- .../SmidgeRuntimeMinifier.cs | 8 - .../Security/BackOfficeUserManager.cs | 4 +- .../Security/ConfigureIISServerOptions.cs | 22 --- .../Security/ConfigureMemberCookieOptions.cs | 2 +- .../Security/ConfigureSecurityStampOptions.cs | 11 +- .../Security/IBackOfficeSignInManager.cs | 4 +- .../Security/IMemberSignInManager.cs | 4 +- .../Security/MemberClaimsPrincipalFactory.cs | 5 +- .../Security/MemberManager.cs | 6 +- .../Security/MemberSignInManager.cs | 8 +- .../Security/PublicAccessChecker.cs | 2 +- .../Security/UmbracoSignInManager.cs | 10 +- .../Umbraco.Web.Common.csproj | 6 +- ...enderingModelValidationMetadataProvider.cs | 18 +++ .../BypassRenderingModelValidatorProvider.cs | 25 +++ src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 17 +- .../Controllers/UmbExternalLoginController.cs | 19 ++- .../Controllers/UmbLoginController.cs | 24 +-- .../Models/ProfileModelBuilder.cs | 2 +- .../Security/MemberAuthenticationBuilder.cs | 4 +- .../Umbraco.Web.Website.csproj | 2 +- templates/Umbraco.Templates.csproj | 2 +- .../UmbracoPackage/UmbracoPackage.csproj | 2 +- .../UmbracoProject/UmbracoProject.csproj | 2 +- .../Umbraco.TestData/Umbraco.TestData.csproj | 2 +- .../misc/umbraco-linux.docker | 4 +- .../Umbraco.Tests.Benchmarks.csproj | 4 +- .../Testing/TestOptionAttributeBase.cs | 3 - .../Umbraco.Tests.Common.csproj | 2 +- .../Umbraco.Core/RuntimeStateTests.cs | 4 +- .../Packaging/PackageDataInstallationTests.cs | 8 +- .../Services/MacroServiceTests.cs | 7 +- .../Services/RelationServiceTests.cs | 8 +- .../Umbraco.Tests.Integration.csproj | 3 +- .../Umbraco.Core/EnumExtensionsTests.cs | 19 --- .../Umbraco.Core/Published/ModelTypeTests.cs | 2 +- ...faultShortStringHelperTestsWithoutSetup.cs | 6 +- .../Security/MemberPasswordHasherTests.cs | 7 +- .../Umbraco.Tests.UnitTests.csproj | 6 +- version.json | 2 +- 201 files changed, 933 insertions(+), 1859 deletions(-) delete mode 100644 src/Umbraco.Core/Composing/IUserComposer.cs delete mode 100644 src/Umbraco.Core/Notifications/UmbracoApplicationComponentsInstallingNotification.cs delete mode 100644 src/Umbraco.Core/Notifications/UmbracoApplicationMainDomAcquiredNotification.cs delete mode 100644 src/Umbraco.Core/Persistence/Repositories/IExternalLoginRepository.cs delete mode 100644 src/Umbraco.Core/Persistence/Repositories/IMacroWithAliasRepository.cs delete mode 100644 src/Umbraco.Core/Services/IExternalLoginService.cs delete mode 100644 src/Umbraco.Core/Services/IMacroWithAliasService.cs create mode 100644 src/Umbraco.Web.Common/Extensions/TypeExtensions.cs delete mode 100644 src/Umbraco.Web.Common/Security/ConfigureIISServerOptions.cs create mode 100644 src/Umbraco.Web.Common/Validators/BypassRenderingModelValidationMetadataProvider.cs create mode 100644 src/Umbraco.Web.Common/Validators/BypassRenderingModelValidatorProvider.cs diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 74e488206e..a3ffc10a1d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,7 +31,8 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v2 with: - dotnet-version: '6.0.x' + dotnet-version: '7.x' + include-prerelease: true - name: dotnet build run: dotnet build umbraco.sln -c SkipTests diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index ae8ca25f52..606e0b6a67 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -64,6 +64,11 @@ stages: gulpFile: src/Umbraco.Web.UI.Client/gulpfile.js targets: coreBuild workingDirectory: src/Umbraco.Web.UI.Client + - task: UseDotNet@2 + displayName: Use .NET 7.x + inputs: + version: 7.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: Run dotnet build inputs: @@ -130,41 +135,41 @@ stages: - task: PowerShell@2 displayName: Install DocFX inputs: - targetType: inline - script: | - choco install docfx --version=2.59.2 -y - if ($lastexitcode -ne 0){ - throw ("Error installing DocFX") - } + targetType: inline + script: | + choco install docfx --version=2.59.2 -y + if ($lastexitcode -ne 0){ + throw ("Error installing DocFX") + } - task: PowerShell@2 displayName: Generate metadata inputs: - targetType: inline - script: | - docfx metadata "$(Build.SourcesDirectory)/build/csharp-docs/docfx.json" - if ($lastexitcode -ne 0){ - throw ("Error generating metadata.") - } + targetType: inline + script: | + docfx metadata "$(Build.SourcesDirectory)/build/csharp-docs/docfx.json" + if ($lastexitcode -ne 0){ + throw ("Error generating metadata.") + } - task: PowerShell@2 displayName: Generate documentation inputs: - targetType: inline - script: | - docfx build "$(Build.SourcesDirectory)/build/csharp-docs/docfx.json" - if ($lastexitcode -ne 0){ - throw ("Error generating documentation.") - } + targetType: inline + script: | + docfx build "$(Build.SourcesDirectory)/build/csharp-docs/docfx.json" + if ($lastexitcode -ne 0){ + throw ("Error generating documentation.") + } - task: ArchiveFiles@2 displayName: Archive C# Docs inputs: - rootFolderOrFile: $(Build.SourcesDirectory)/build/csharp-docs/_site - includeRootFolder: false - archiveFile: $(Build.ArtifactStagingDirectory)/csharp-docs.zip + rootFolderOrFile: $(Build.SourcesDirectory)/build/csharp-docs/_site + includeRootFolder: false + archiveFile: $(Build.ArtifactStagingDirectory)/csharp-docs.zip - task: PublishPipelineArtifact@1 displayName: Publish C# Docs inputs: - targetPath: $(Build.ArtifactStagingDirectory)/csharp-docs.zip - artifact: csharp-docs + targetPath: $(Build.ArtifactStagingDirectory)/csharp-docs.zip + artifact: csharp-docs # js API Reference - job: @@ -192,14 +197,14 @@ stages: - task: ArchiveFiles@2 displayName: Archive js Docs inputs: - rootFolderOrFile: $(Build.SourcesDirectory)/src/Umbraco.Web.UI.Docs/api - includeRootFolder: false - archiveFile: $(Build.ArtifactStagingDirectory)/ui-docs.zip + rootFolderOrFile: $(Build.SourcesDirectory)/src/Umbraco.Web.UI.Docs/api + includeRootFolder: false + archiveFile: $(Build.ArtifactStagingDirectory)/ui-docs.zip - task: PublishPipelineArtifact@1 displayName: Publish js Docs inputs: - targetPath: $(Build.ArtifactStagingDirectory)/ui-docs.zip - artifact: ui-docs + targetPath: $(Build.ArtifactStagingDirectory)/ui-docs.zip + artifact: ui-docs ############################################### ## Test @@ -228,10 +233,10 @@ stages: artifact: build_output path: $(Build.SourcesDirectory) - task: UseDotNet@2 - condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) # net6 already on the other images - displayName: Use net6 + displayName: Use net7 inputs: - version: 6.x + version: 7.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: Run dotnet test inputs: @@ -264,10 +269,10 @@ stages: artifact: build_output path: $(Build.SourcesDirectory) - task: UseDotNet@2 - displayName: Use net6 - condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) # net6 already on the other images + displayName: Use net7 inputs: - version: 6.x + version: 7.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: Run dotnet test inputs: @@ -305,7 +310,7 @@ stages: - powershell: sqllocaldb start mssqllocaldb displayName: Start localdb (Windows only) condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - - powershell: docker run --name mssql -d -p 1433:1433 -e ACCEPT_EULA=Y -e SA_PASSWORD=$(SA_PASSWORD) -e MSSQL_PID=Developer mcr.microsoft.com/mssql/server:2019-latest + - powershell: docker run --name mssql -d -p 1433:1433 -e ACCEPT_EULA=Y -e SA_PASSWORD=$(SA_PASSWORD) -e MSSQL_PID=Developer mcr.microsoft.com/mssql/server:2019-latest displayName: Start SQL Server (Linux only) condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) - task: DotNetCoreCLI@2 @@ -327,7 +332,7 @@ stages: displayName: E2E Tests dependsOn: Build jobs: - # E2E Tests + # E2E Tests - job: displayName: E2E Tests variables: @@ -358,7 +363,7 @@ stages: Windows: vmImage: 'windows-latest' pool: - vmImage: $(vmImage) + vmImage: $(vmImage) steps: - task: DownloadPipelineArtifact@2 displayName: Download nupkg @@ -397,7 +402,12 @@ stages: - powershell: Invoke-Sqlcmd -Query "CREATE DATABASE $env:UmbracoDatabaseName" -ServerInstance $env:UmbracoDatabaseServer displayName: Create database (Windows only) condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - # Linux containers smooth + - task: UseDotNet@2 + displayName: Use .Net 7.x + inputs: + version: 7.x + includePreviewVersions: true + # Linux containers smooth - task: PowerShell@2 condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) displayName: Build & run container (Linux only) @@ -482,14 +492,17 @@ stages: inputs: artifact: nupkg path: $(Build.ArtifactStagingDirectory)/nupkg - - task: NuGetCommand@2 - displayName: Nuget push + - task: DotNetCoreCLI@2 + displayName: dotnet restore inputs: - command: 'push' - packagesToPush: $(Build.ArtifactStagingDirectory)/**/*.nupkg - nuGetFeedType: 'external' - publishFeedCredentials: 'MyGet - Pre-releases' - + command: restore + projects: '**/umbraco.sln' + # TODO: Use NuGetCommand instead of DotNetCoreCLI + # - task: NuGetCommand@2 + # displayName: Restore NuGet Packages + # inputs: + # restoreSolution: 'umbraco.sln' + # feedsToUse: config - stage: Deploy_NuGet displayName: NuGet release dependsOn: @@ -506,13 +519,11 @@ stages: inputs: artifact: nupkg path: $(Build.ArtifactStagingDirectory)/nupkg - - task: NuGetCommand@2 - displayName: Nuget push + - task: DotNetCoreCLI@2 + displayName: dotnet restore inputs: - command: 'push' - packagesToPush: $(Build.ArtifactStagingDirectory)/**/*.nupkg - nuGetFeedType: 'external' - publishFeedCredentials: 'NuGet - Umbraco.*' + command: restore + projects: '**/umbraco.sln' - stage: Upload_API_Docs pool: diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ce54e08edd..657774fcc0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -7,7 +7,7 @@ 10.0.0 10.0.0-rc1 10.0.0 - 10.0 + preview en-US Umbraco CMS Copyright © Umbraco 2021 @@ -44,10 +44,11 @@ - - true - 10.0.0 - true - true - + + + + + + + diff --git a/src/JsonSchema/JsonSchema.csproj b/src/JsonSchema/JsonSchema.csproj index 551d96f1fb..8fa11a4bee 100644 --- a/src/JsonSchema/JsonSchema.csproj +++ b/src/JsonSchema/JsonSchema.csproj @@ -1,7 +1,7 @@ Exe - net6.0 + net7.0 true false false diff --git a/src/Umbraco.Cms.ManagementApi/ManagementApiComposer.cs b/src/Umbraco.Cms.ManagementApi/ManagementApiComposer.cs index f0921f2244..1f57d99e4a 100644 --- a/src/Umbraco.Cms.ManagementApi/ManagementApiComposer.cs +++ b/src/Umbraco.Cms.ManagementApi/ManagementApiComposer.cs @@ -62,9 +62,10 @@ public class ManagementApiComposer : IComposer // Not super happy with this, but we need to know the UmbracoPath when registering the controller // To be able to replace the route template token + // TODO this is fixed in Bjarkes PR for v10, and will need to be removed in v11 merge GlobalSettings? globalSettings = builder.Config.GetSection(Constants.Configuration.ConfigGlobal).Get(); - var backofficePath = globalSettings.UmbracoPath.TrimStart(Constants.CharArrays.TildeForwardSlash); + var backofficePath = (globalSettings?.UmbracoPath ?? new GlobalSettings().UmbracoPath).TrimStart(Constants.CharArrays.TildeForwardSlash); services.AddControllers(options => { diff --git a/src/Umbraco.Cms.ManagementApi/Umbraco.Cms.ManagementApi.csproj b/src/Umbraco.Cms.ManagementApi/Umbraco.Cms.ManagementApi.csproj index 2fd111bfa8..a3a34e178b 100644 --- a/src/Umbraco.Cms.ManagementApi/Umbraco.Cms.ManagementApi.csproj +++ b/src/Umbraco.Cms.ManagementApi/Umbraco.Cms.ManagementApi.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable nullable diff --git a/src/Umbraco.Cms.Persistence.SqlServer/Umbraco.Cms.Persistence.SqlServer.csproj b/src/Umbraco.Cms.Persistence.SqlServer/Umbraco.Cms.Persistence.SqlServer.csproj index e206cd8653..e78c210ae2 100644 --- a/src/Umbraco.Cms.Persistence.SqlServer/Umbraco.Cms.Persistence.SqlServer.csproj +++ b/src/Umbraco.Cms.Persistence.SqlServer/Umbraco.Cms.Persistence.SqlServer.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Persistence.SqlServer Umbraco.Cms.Persistence.SqlServer Adds support for SQL Server to Umbraco CMS. diff --git a/src/Umbraco.Cms.Persistence.Sqlite/Umbraco.Cms.Persistence.Sqlite.csproj b/src/Umbraco.Cms.Persistence.Sqlite/Umbraco.Cms.Persistence.Sqlite.csproj index 5aa062df17..943757b353 100644 --- a/src/Umbraco.Cms.Persistence.Sqlite/Umbraco.Cms.Persistence.Sqlite.csproj +++ b/src/Umbraco.Cms.Persistence.Sqlite/Umbraco.Cms.Persistence.Sqlite.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Persistence.Sqlite Umbraco.Cms.Persistence.Sqlite Adds support for SQLite to Umbraco CMS. @@ -12,6 +12,7 @@ + diff --git a/src/Umbraco.Cms.StaticAssets/Umbraco.Cms.StaticAssets.csproj b/src/Umbraco.Cms.StaticAssets/Umbraco.Cms.StaticAssets.csproj index 1fbbd8c42f..89cb8a44aa 100644 --- a/src/Umbraco.Cms.StaticAssets/Umbraco.Cms.StaticAssets.csproj +++ b/src/Umbraco.Cms.StaticAssets/Umbraco.Cms.StaticAssets.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 true Umbraco.Cms.StaticAssets Contains the static assets that is required to run Umbraco CMS. diff --git a/src/Umbraco.Cms/Umbraco.Cms.csproj b/src/Umbraco.Cms/Umbraco.Cms.csproj index c6c63108ff..ce43dc67fc 100644 --- a/src/Umbraco.Cms/Umbraco.Cms.csproj +++ b/src/Umbraco.Cms/Umbraco.Cms.csproj @@ -1,6 +1,6 @@ - net6.0 + net7.0 false Umbraco.Cms Umbraco.Cms diff --git a/src/Umbraco.Core/Composing/IUserComposer.cs b/src/Umbraco.Core/Composing/IUserComposer.cs deleted file mode 100644 index a3e45054f8..0000000000 --- a/src/Umbraco.Core/Composing/IUserComposer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Umbraco.Cms.Core.Composing; - -/// -/// Represents a user . -/// -[Obsolete("This interface is obsolete. Use IComposer instead.")] -public interface IUserComposer : IComposer -{ -} diff --git a/src/Umbraco.Core/Configuration/ConfigureConnectionStrings.cs b/src/Umbraco.Core/Configuration/ConfigureConnectionStrings.cs index cd256e1b45..69ef69239e 100644 --- a/src/Umbraco.Core/Configuration/ConfigureConnectionStrings.cs +++ b/src/Umbraco.Core/Configuration/ConfigureConnectionStrings.cs @@ -23,8 +23,13 @@ public class ConfigureConnectionStrings : IConfigureNamedOptions Configure(Options.DefaultName, options); /// - public void Configure(string name, ConnectionStrings options) + public void Configure(string? name, ConnectionStrings options) { + if (name is null) + { + throw new InvalidOperationException("The name of the option instance is required."); + } + // Default to using UmbracoConnectionName if (name == Options.DefaultName) { diff --git a/src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs b/src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs index 0c5d39f47a..672577b1b7 100644 --- a/src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs @@ -19,30 +19,36 @@ public class RequestHandlerSettings internal static readonly CharItem[] DefaultCharCollection = { - new () { Char = " ", Replacement = "-" }, - new () { Char = "\"", Replacement = string.Empty }, - new () { Char = "'", Replacement = string.Empty }, - new () { Char = "%", Replacement = string.Empty }, - new () { Char = ".", Replacement = string.Empty }, - new () { Char = ";", Replacement = string.Empty }, - new () { Char = "/", Replacement = string.Empty }, - new () { Char = "\\", Replacement = string.Empty }, - new () { Char = ":", Replacement = string.Empty }, - new () { Char = "#", Replacement = string.Empty }, - new () { Char = "+", Replacement = "plus" }, - new () { Char = "*", Replacement = "star" }, - new () { Char = "&", Replacement = string.Empty }, - new () { Char = "?", Replacement = string.Empty }, - new () { Char = "æ", Replacement = "ae" }, - new () { Char = "ä", Replacement = "ae" }, - new () { Char = "ø", Replacement = "oe" }, - new () { Char = "ö", Replacement = "oe" }, - new () { Char = "å", Replacement = "aa" }, - new () { Char = "ü", Replacement = "ue" }, - new () { Char = "ß", Replacement = "ss" }, - new () { Char = "|", Replacement = "-" }, - new () { Char = "<", Replacement = string.Empty }, - new () { Char = ">", Replacement = string.Empty }, + new() { Char = " ", Replacement = "-" }, + new() { Char = "\"", Replacement = string.Empty }, + new() { Char = "'", Replacement = string.Empty }, + new() { Char = "%", Replacement = string.Empty }, + new() { Char = ".", Replacement = string.Empty }, + new() { Char = ";", Replacement = string.Empty }, + new() { Char = "/", Replacement = string.Empty }, + new() { Char = "\\", Replacement = string.Empty }, + new() { Char = ":", Replacement = string.Empty }, + new() { Char = "#", Replacement = string.Empty }, + new() { Char = "&", Replacement = string.Empty }, + new() { Char = "?", Replacement = string.Empty }, + new() { Char = "<", Replacement = string.Empty }, + new() { Char = ">", Replacement = string.Empty }, + new() { Char = "+", Replacement = "plus" }, + new() { Char = "*", Replacement = "star" }, + new() { Char = "æ", Replacement = "ae" }, + new() { Char = "Æ", Replacement = "ae" }, + new() { Char = "ä", Replacement = "ae" }, + new() { Char = "Ä", Replacement = "ae" }, + new() { Char = "ø", Replacement = "oe" }, + new() { Char = "Ø", Replacement = "oe" }, + new() { Char = "ö", Replacement = "oe" }, + new() { Char = "Ö", Replacement = "oe" }, + new() { Char = "å", Replacement = "aa" }, + new() { Char = "Å", Replacement = "aa" }, + new() { Char = "ü", Replacement = "ue" }, + new() { Char = "Ü", Replacement = "ue" }, + new() { Char = "ß", Replacement = "ss" }, + new() { Char = "|", Replacement = "-" }, }; /// @@ -73,13 +79,6 @@ public class RequestHandlerSettings [DefaultValue(StaticEnableDefaultCharReplacements)] public bool EnableDefaultCharReplacements { get; set; } = StaticEnableDefaultCharReplacements; - /// - /// Add additional character replacements, or override defaults - /// - [Obsolete( - "Use the GetCharReplacements extension method in the Umbraco.Extensions namespace instead. Scheduled for removal in V11")] - public IEnumerable CharCollection { get; set; } = DefaultCharCollection; - /// /// Add additional character replacements, or override defaults /// diff --git a/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs index 0798014600..5062dc87e4 100644 --- a/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs +++ b/src/Umbraco.Core/Configuration/Models/Validation/ContentSettingsValidator.cs @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Configuration.Models.Validation; public class ContentSettingsValidator : ConfigurationValidatorBase, IValidateOptions { /// - public ValidateOptionsResult Validate(string name, ContentSettings options) + public ValidateOptionsResult Validate(string? name, ContentSettings options) { if (!ValidateError404Collection(options.Error404Collection, out var message)) { diff --git a/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs index 32ad130c33..f78ce306dd 100644 --- a/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs +++ b/src/Umbraco.Core/Configuration/Models/Validation/GlobalSettingsValidator.cs @@ -12,7 +12,7 @@ public class GlobalSettingsValidator : ConfigurationValidatorBase, IValidateOptions { /// - public ValidateOptionsResult Validate(string name, GlobalSettings options) + public ValidateOptionsResult Validate(string? name, GlobalSettings options) { if (!ValidateSmtpSetting(options.Smtp, out var message)) { diff --git a/src/Umbraco.Core/Configuration/Models/Validation/HealthChecksSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/HealthChecksSettingsValidator.cs index ac0e1651ea..2b55afdcb0 100644 --- a/src/Umbraco.Core/Configuration/Models/Validation/HealthChecksSettingsValidator.cs +++ b/src/Umbraco.Core/Configuration/Models/Validation/HealthChecksSettingsValidator.cs @@ -19,7 +19,7 @@ public class HealthChecksSettingsValidator : ConfigurationValidatorBase, IValida public HealthChecksSettingsValidator(ICronTabParser cronTabParser) => _cronTabParser = cronTabParser; /// - public ValidateOptionsResult Validate(string name, HealthChecksSettings options) + public ValidateOptionsResult Validate(string? name, HealthChecksSettings options) { if (!ValidateNotificationFirstRunTime(options.Notification.FirstRunTime, out var message)) { diff --git a/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs index 4a1872cf30..8515fc3cc4 100644 --- a/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs +++ b/src/Umbraco.Core/Configuration/Models/Validation/RequestHandlerSettingsValidator.cs @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Configuration.Models.Validation; public class RequestHandlerSettingsValidator : ConfigurationValidatorBase, IValidateOptions { /// - public ValidateOptionsResult Validate(string name, RequestHandlerSettings options) + public ValidateOptionsResult Validate(string? name, RequestHandlerSettings options) { if (!ValidateConvertUrlsToAscii(options.ConvertUrlsToAscii, out var message)) { diff --git a/src/Umbraco.Core/Configuration/Models/Validation/UnattendedSettingsValidator.cs b/src/Umbraco.Core/Configuration/Models/Validation/UnattendedSettingsValidator.cs index e262de76e7..473224553a 100644 --- a/src/Umbraco.Core/Configuration/Models/Validation/UnattendedSettingsValidator.cs +++ b/src/Umbraco.Core/Configuration/Models/Validation/UnattendedSettingsValidator.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. using Microsoft.Extensions.Options; @@ -12,7 +12,7 @@ public class UnattendedSettingsValidator : IValidateOptions { /// - public ValidateOptionsResult Validate(string name, UnattendedSettings options) + public ValidateOptionsResult Validate(string? name, UnattendedSettings options) { if (options.InstallUnattended) { diff --git a/src/Umbraco.Core/Constants-Conventions.cs b/src/Umbraco.Core/Constants-Conventions.cs index 7b221e1435..22acf8cc4d 100644 --- a/src/Umbraco.Core/Constants-Conventions.cs +++ b/src/Umbraco.Core/Constants-Conventions.cs @@ -178,68 +178,6 @@ public static partial class Constants public const string CommentsLabel = "Comments"; - /// - /// Property alias for the Approved boolean of a Member - /// - [Obsolete( - "IsApproved is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string IsApproved = "umbracoMemberApproved"; - - [Obsolete("Use the stateApproved translation in the user area instead, scheduled for removal in V11")] - public const string IsApprovedLabel = "Is Approved"; - - /// - /// Property alias for the Locked out boolean of a Member - /// - [Obsolete( - "IsLockedOut is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string IsLockedOut = "umbracoMemberLockedOut"; - - [Obsolete("Use the stateLockedOut translation in the user area instead, scheduled for removal in V11")] - public const string IsLockedOutLabel = "Is Locked Out"; - - /// - /// Property alias for the last date the Member logged in - /// - [Obsolete( - "LastLoginDate is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string LastLoginDate = "umbracoMemberLastLogin"; - - [Obsolete("Use the lastLogin translation in the user area instead, scheduled for removal in V11")] - public const string LastLoginDateLabel = "Last Login Date"; - - /// - /// Property alias for the last date a Member changed its password - /// - [Obsolete( - "LastPasswordChangeDate is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string LastPasswordChangeDate = "umbracoMemberLastPasswordChangeDate"; - - [Obsolete( - "Use the lastPasswordChangeDate translation in the user area instead, scheduled for removal in V11")] - public const string LastPasswordChangeDateLabel = "Last Password Change Date"; - - /// - /// Property alias for the last date a Member was locked out - /// - [Obsolete( - "LastLockoutDate is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string LastLockoutDate = "umbracoMemberLastLockoutDate"; - - [Obsolete("Use the lastLockoutDate translation in the user area instead, scheduled for removal in V11")] - public const string LastLockoutDateLabel = "Last Lockout Date"; - - /// - /// Property alias for the number of failed login attempts - /// - [Obsolete( - "FailedPasswordAttempts is no longer property data, access the property directly on IMember instead, scheduled for removal in V11")] - public const string FailedPasswordAttempts = "umbracoMemberFailedPasswordAttempts"; - - [Obsolete( - "Use the failedPasswordAttempts translation in the user area instead, scheduled for removal in V11")] - public const string FailedPasswordAttemptsLabel = "Failed Password Attempts"; - /// /// The standard properties group alias for membership properties. /// diff --git a/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs b/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs index ec26080e76..579a34894a 100644 --- a/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Umbraco.Core/DependencyInjection/ServiceCollectionExtensions.cs @@ -68,16 +68,7 @@ public static class ServiceCollectionExtensions services.AddUnique(factory => (TImplementing)factory.GetRequiredService(), lifetime); } - // TODO(V11): Remove this function. - [Obsolete("This method is functionally equivalent to AddSingleton() please use that instead.")] - public static void AddUnique(this IServiceCollection services) - where TImplementing : class - { - services.RemoveAll(); - services.AddSingleton(); - } - - /// + /// /// Adds a service of type with an implementation factory method to the specified /// . /// diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs index c409a849ec..fc78d985f7 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.CollectionBuilders.cs @@ -84,12 +84,8 @@ public static partial class UmbracoBuilderExtensions return builder; } - [Obsolete("Use AddEmbedProvider instead. This will be removed in Umbraco 11")] - public static IUmbracoBuilder AddOEmbedProvider(this IUmbracoBuilder builder) - where T : class, IEmbedProvider => AddEmbedProvider(builder); - /// - /// Register a section. + /// Register a section. /// /// The type of the section. /// The builder. diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs index c699e09743..280d7ce492 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs @@ -272,14 +272,6 @@ public static partial class UmbracoBuilderExtensions public static MediaUrlGeneratorCollectionBuilder MediaUrlGenerators(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); - /// - /// Gets the backoffice OEmbed Providers collection builder. - /// - /// The builder. - [Obsolete("Use EmbedProviders() instead")] - public static EmbedProvidersCollectionBuilder OEmbedProviders(this IUmbracoBuilder builder) - => EmbedProviders(builder); - /// /// Gets the backoffice Embed Providers collection builder. /// diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Configuration.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Configuration.cs index 6efd096c68..31ef06c400 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Configuration.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Configuration.cs @@ -103,8 +103,6 @@ public static partial class UmbracoBuilderExtensions Constants.Configuration.NamedOptions.InstallDefaultData.MemberTypes, builder.Config.GetSection($"{Constants.Configuration.ConfigInstallDefaultData}:{Constants.Configuration.NamedOptions.InstallDefaultData.MemberTypes}")); - builder.Services.Configure(options => options.MergeReplacements(builder.Config)); - // TODO: Remove this in V12 // This is to make the move of the AllowEditInvariantFromNonDefault setting from SecuritySettings to ContentSettings backwards compatible // If there is a value in security settings, but no value in content setting we'll use that value, otherwise content settings always wins. diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index 4bfe7fd7bd..d806950584 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -307,7 +307,6 @@ namespace Umbraco.Cms.Core.DependencyInjection factory.GetRequiredService(), factory.GetRequiredService() )); - Services.AddUnique(factory => factory.GetRequiredService()); Services.AddUnique(factory => factory.GetRequiredService()); Services.AddUnique(factory => new LocalizedTextService( factory.GetRequiredService>(), diff --git a/src/Umbraco.Core/Extensions/EnumExtensions.cs b/src/Umbraco.Core/Extensions/EnumExtensions.cs index 3aa124d2f3..c88a2d8b2f 100644 --- a/src/Umbraco.Core/Extensions/EnumExtensions.cs +++ b/src/Umbraco.Core/Extensions/EnumExtensions.cs @@ -1,42 +1,31 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. -namespace Umbraco.Extensions; +using System; -/// -/// Provides extension methods to . -/// -public static class EnumExtensions +namespace Umbraco.Extensions { /// - /// Determines whether all the flags/bits are set within the enum value. + /// Provides extension methods to . /// - /// The enum type. - /// The enum value. - /// The flags. - /// - /// true if all the flags/bits are set within the enum value; otherwise, false. - /// - [Obsolete("Use Enum.HasFlag() or bitwise operations (if performance is important) instead.")] - public static bool HasFlagAll(this T value, T flags) - where T : Enum => - value.HasFlag(flags); - - /// - /// Determines whether any of the flags/bits are set within the enum value. - /// - /// The enum type. - /// The value. - /// The flags. - /// - /// true if any of the flags/bits are set within the enum value; otherwise, false. - /// - public static bool HasFlagAny(this T value, T flags) - where T : Enum + public static class EnumExtensions { - var v = Convert.ToUInt64(value); - var f = Convert.ToUInt64(flags); + /// + /// Determines whether any of the flags/bits are set within the enum value. + /// + /// The enum type. + /// The value. + /// The flags. + /// + /// true if any of the flags/bits are set within the enum value; otherwise, false. + /// + public static bool HasFlagAny(this T value, T flags) + where T : Enum + { + var v = Convert.ToUInt64(value); + var f = Convert.ToUInt64(flags); - return (v & f) > 0; + return (v & f) > 0; + } } } diff --git a/src/Umbraco.Core/Extensions/RequestHandlerSettingsExtension.cs b/src/Umbraco.Core/Extensions/RequestHandlerSettingsExtension.cs index 475f093785..8699950b37 100644 --- a/src/Umbraco.Core/Extensions/RequestHandlerSettingsExtension.cs +++ b/src/Umbraco.Core/Extensions/RequestHandlerSettingsExtension.cs @@ -7,13 +7,13 @@ namespace Umbraco.Extensions; /// /// Get concatenated user and default character replacements -/// taking into account +/// taking into account . /// public static class RequestHandlerSettingsExtension { /// /// Get concatenated user and default character replacements - /// taking into account + /// taking into account . /// public static IEnumerable GetCharReplacements(this RequestHandlerSettings requestHandlerSettings) { @@ -28,31 +28,8 @@ public static class RequestHandlerSettingsExtension return RequestHandlerSettings.DefaultCharCollection; } - return MergeUnique( - requestHandlerSettings.UserDefinedCharCollection, - RequestHandlerSettings.DefaultCharCollection); - } - - /// - /// Merges CharCollection and UserDefinedCharCollection, prioritizing UserDefinedCharCollection - /// - internal static void MergeReplacements( - this RequestHandlerSettings requestHandlerSettings, - IConfiguration configuration) - { - var sectionKey = $"{Constants.Configuration.ConfigRequestHandler}:"; - - IEnumerable charCollection = GetReplacements( - configuration, - $"{sectionKey}{nameof(RequestHandlerSettings.CharCollection)}"); - - IEnumerable userDefinedCharCollection = GetReplacements( - configuration, - $"{sectionKey}{nameof(requestHandlerSettings.UserDefinedCharCollection)}"); - - IEnumerable mergedCollection = MergeUnique(userDefinedCharCollection, charCollection); - - requestHandlerSettings.UserDefinedCharCollection = mergedCollection; + /// Merges CharCollection and UserDefinedCharCollection, prioritizing UserDefinedCharCollection. + return MergeUnique(requestHandlerSettings.UserDefinedCharCollection, RequestHandlerSettings.DefaultCharCollection); } private static IEnumerable GetReplacements(IConfiguration configuration, string key) @@ -64,6 +41,12 @@ public static class RequestHandlerSettingsExtension { var @char = section.GetValue(nameof(CharItem.Char)); var replacement = section.GetValue(nameof(CharItem.Replacement)); + + if (@char is null || replacement is null) + { + continue; + } + replacements.Add(new CharItem { Char = @char, Replacement = replacement }); } @@ -71,8 +54,7 @@ public static class RequestHandlerSettingsExtension } /// - /// Merges two IEnumerable of CharItem without any duplicates, items in priorityReplacements will override those in - /// alternativeReplacements + /// Merges two IEnumerable of CharItem without any duplicates, items in priorityReplacements will override those in alternativeReplacements. /// private static IEnumerable MergeUnique( IEnumerable priorityReplacements, diff --git a/src/Umbraco.Core/HealthChecks/Checks/Security/BaseHttpHeaderCheck.cs b/src/Umbraco.Core/HealthChecks/Checks/Security/BaseHttpHeaderCheck.cs index 5e830e1f61..9a0ecf57ae 100644 --- a/src/Umbraco.Core/HealthChecks/Checks/Security/BaseHttpHeaderCheck.cs +++ b/src/Umbraco.Core/HealthChecks/Checks/Security/BaseHttpHeaderCheck.cs @@ -19,18 +19,6 @@ public abstract class BaseHttpHeaderCheck : HealthCheck private readonly string _localizedTextPrefix; private readonly bool _metaTagOptionAvailable; - [Obsolete("Use ctor without value.")] - protected BaseHttpHeaderCheck( - IHostingEnvironment hostingEnvironment, - ILocalizedTextService textService, - string header, - string value, - string localizedTextPrefix, - bool metaTagOptionAvailable) - : this(hostingEnvironment, textService, header, localizedTextPrefix, metaTagOptionAvailable) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs index b8960048f6..1dfa72039c 100644 --- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs +++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs @@ -2,7 +2,7 @@ namespace Umbraco.Cms.Core.Hosting; public interface IHostingEnvironment { - string SiteName { get; } + string? SiteName { get; } /// /// The unique application ID for this Umbraco website. diff --git a/src/Umbraco.Core/IO/ViewHelper.cs b/src/Umbraco.Core/IO/ViewHelper.cs index e2502e4669..e68101918a 100644 --- a/src/Umbraco.Core/IO/ViewHelper.cs +++ b/src/Umbraco.Core/IO/ViewHelper.cs @@ -11,21 +11,11 @@ public class ViewHelper : IViewHelper private readonly IDefaultViewContentProvider _defaultViewContentProvider; private readonly IFileSystem _viewFileSystem; - [Obsolete("Use ctor with all params")] - public ViewHelper(IFileSystem viewFileSystem) - { - _viewFileSystem = viewFileSystem ?? throw new ArgumentNullException(nameof(viewFileSystem)); - _defaultViewContentProvider = StaticServiceProvider.Instance.GetRequiredService(); - } - - public ViewHelper(FileSystems fileSystems, IDefaultViewContentProvider defaultViewContentProvider) - { - _viewFileSystem = fileSystems.MvcViewsFileSystem ?? throw new ArgumentNullException(nameof(fileSystems)); - _defaultViewContentProvider = defaultViewContentProvider ?? - throw new ArgumentNullException(nameof(defaultViewContentProvider)); - } - - [Obsolete("Inject IDefaultViewContentProvider instead")] + public ViewHelper(FileSystems fileSystems, IDefaultViewContentProvider defaultViewContentProvider) + { + _viewFileSystem = fileSystems.MvcViewsFileSystem ?? throw new ArgumentNullException(nameof(fileSystems)); + _defaultViewContentProvider = defaultViewContentProvider ?? throw new ArgumentNullException(nameof(defaultViewContentProvider)); + }[Obsolete("Inject IDefaultViewContentProvider instead")] public static string GetDefaultFileContent(string? layoutPageAlias = null, string? modelClassName = null, string? modelNamespace = null, string? modelNamespaceAlias = null) { IDefaultViewContentProvider viewContentProvider = diff --git a/src/Umbraco.Core/Install/InstallSteps/TelemetryIdentifierStep.cs b/src/Umbraco.Core/Install/InstallSteps/TelemetryIdentifierStep.cs index 6db33486f5..17b89d8ec0 100644 --- a/src/Umbraco.Core/Install/InstallSteps/TelemetryIdentifierStep.cs +++ b/src/Umbraco.Core/Install/InstallSteps/TelemetryIdentifierStep.cs @@ -29,20 +29,11 @@ public class TelemetryIdentifierStep : InstallSetupStep _siteIdentifierService = siteIdentifierService; } - [Obsolete("Use constructor that takes GlobalSettings and ISiteIdentifierService")] - public TelemetryIdentifierStep( - ILogger logger, - IOptions globalSettings, - IConfigManipulator configManipulator) - : this(globalSettings, StaticServiceProvider.Instance.GetRequiredService()) - { - } - - public override Task ExecuteAsync(object model) - { - _siteIdentifierService.TryCreateSiteIdentifier(out _); - return Task.FromResult(null); - } + public override Task ExecuteAsync(object model) + { + _siteIdentifierService.TryCreateSiteIdentifier(out _); + return Task.FromResult(null); + } public override bool RequiresExecution(object model) { diff --git a/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs index ab3c36031c..3953fdd2b7 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Dailymotion the popular online video-sharing platform. /// -public class DailyMotion : EmbedProviderBase +public class DailyMotion : OEmbedProviderBase { public DailyMotion(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs index d0a8727442..e51005b84b 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs @@ -2,7 +2,7 @@ using Umbraco.Cms.Core.Serialization; namespace Umbraco.Cms.Core.Media.EmbedProviders; -[Obsolete("Use OEmbedProviderBase instead- This will be removed in Umbraco 12")] +[Obsolete("Use OEmbedProviderBase instead")] public abstract class EmbedProviderBase : OEmbedProviderBase { protected EmbedProviderBase(IJsonSerializer jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs index e1842ed238..7738981fe9 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs @@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Flickr the popular online image hosting and video hosting service. /// -public class Flickr : EmbedProviderBase +public class Flickr : OEmbedProviderBase { public Flickr(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs index cd045d7df3..5341580967 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Getty Images supplier of stock images, editorial photography, video and music for business and consumers. /// -public class GettyImages : EmbedProviderBase +public class GettyImages : OEmbedProviderBase { public GettyImages(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs index 3a6ad54204..a7fde54f18 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Giphy.com the popular online GIFs and animated sticker provider. /// -public class Giphy : EmbedProviderBase +public class Giphy : OEmbedProviderBase { public Giphy(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs index 87bc0524e4..85c1214fd1 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Hulu the the popular online subscription streaming service. /// -public class Hulu : EmbedProviderBase +public class Hulu : OEmbedProviderBase { public Hulu(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs index 7da51b51ad..1a53ad88d1 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Issuu the popular platform to create interactive flipbooks, social media posts, GIFs, and more from a single piece of static content. /// -public class Issuu : EmbedProviderBase +public class Issuu : OEmbedProviderBase { public Issuu(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs index fecfd8606b..daf1cc25f9 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Kickstarter the popular online crowdfunding platform focused on creativity. /// -public class Kickstarter : EmbedProviderBase +public class Kickstarter : OEmbedProviderBase { public Kickstarter(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs index 1791034168..33802fa059 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for SlideShare for professional online content including presentations, infographics, documents, and videos. /// -public class Slideshare : EmbedProviderBase +public class Slideshare : OEmbedProviderBase { public Slideshare(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs index ccb3104940..2d59031b63 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for SoundCloud the popular online audio distribution platform and music sharing provider. /// -public class Soundcloud : EmbedProviderBase +public class Soundcloud : OEmbedProviderBase { public Soundcloud(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Ted.cs b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs index 1e7981f7af..5fcc7fcb42 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Ted.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Ted that posts talks online for free distribution. /// -public class Ted : EmbedProviderBase +public class Ted : OEmbedProviderBase { public Ted(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs index af2c723533..81aeb36491 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Twitter the popular online service for microblogging and social networking. /// -public class Twitter : EmbedProviderBase +public class Twitter : OEmbedProviderBase { public Twitter(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs index 0159e59cbd..e4d19d463a 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs @@ -6,7 +6,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for Vimeo the popular online video hosting, sharing, and services platform provider. /// -public class Vimeo : EmbedProviderBase +public class Vimeo : OEmbedProviderBase { public Vimeo(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs index ceb8af99e9..30cf2e6016 100644 --- a/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs @@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core.Media.EmbedProviders; /// /// Embed Provider for YouTube the popular online video sharing and social media platform provider. /// -public class YouTube : EmbedProviderBase +public class YouTube : OEmbedProviderBase { public YouTube(IJsonSerializer jsonSerializer) : base(jsonSerializer) diff --git a/src/Umbraco.Core/Models/ChangingPasswordModel.cs b/src/Umbraco.Core/Models/ChangingPasswordModel.cs index 946bcde9ab..ecba35f137 100644 --- a/src/Umbraco.Core/Models/ChangingPasswordModel.cs +++ b/src/Umbraco.Core/Models/ChangingPasswordModel.cs @@ -11,7 +11,7 @@ public class ChangingPasswordModel /// The password value /// [DataMember(Name = "newPassword")] - public string? NewPassword { get; set; } + public required string NewPassword { get; set; } /// /// The old password - used to change a password when: EnablePasswordRetrieval = false diff --git a/src/Umbraco.Core/Models/ContentEditing/UserGroupPermissionsSave.cs b/src/Umbraco.Core/Models/ContentEditing/UserGroupPermissionsSave.cs index 1c04496e04..1e648f949f 100644 --- a/src/Umbraco.Core/Models/ContentEditing/UserGroupPermissionsSave.cs +++ b/src/Umbraco.Core/Models/ContentEditing/UserGroupPermissionsSave.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Umbraco.Extensions; @@ -22,13 +22,4 @@ public class UserGroupPermissionsSave /// [DataMember(Name = "permissions")] public IDictionary> AssignedPermissions { get; set; } - - [Obsolete("This is not used and will be removed in Umbraco 10")] - public IEnumerable Validate(ValidationContext validationContext) - { - if (AssignedPermissions.SelectMany(x => x.Value).Any(x => x.IsNullOrWhiteSpace())) - { - yield return new ValidationResult("A permission value cannot be null or empty", new[] { "Permissions" }); - } - } } diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index f4fe617a83..c31f5f72ff 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Models; /// [Serializable] [DataContract(IsReference = true)] -public class ContentType : ContentTypeCompositionBase, IContentTypeWithHistoryCleanup +public class ContentType : ContentTypeCompositionBase, IContentType { public const bool SupportsPublishingConst = true; diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs index 5d76c49b88..f43764faeb 100644 --- a/src/Umbraco.Core/Models/IContentType.cs +++ b/src/Umbraco.Core/Models/IContentType.cs @@ -2,19 +2,6 @@ using Umbraco.Cms.Core.Models.ContentEditing; namespace Umbraco.Cms.Core.Models; -/// -/// Defines a content type that contains a history cleanup policy. -/// -[Obsolete("This will be merged into IContentType in Umbraco 10.")] -public interface IContentTypeWithHistoryCleanup : IContentType -{ - /// - /// Gets or sets the history cleanup configuration. - /// - /// The history cleanup configuration. - HistoryCleanup? HistoryCleanup { get; set; } -} - /// /// Defines a ContentType, which Content is based on /// @@ -68,4 +55,10 @@ public interface IContentType : IContentTypeComposition /// /// IContentType DeepCloneWithResetIdentities(string newAlias); + + /// + /// Gets or sets the history cleanup configuration. + /// + /// The history cleanup configuration. + HistoryCleanup? HistoryCleanup { get; set; } } diff --git a/src/Umbraco.Core/Models/Language.cs b/src/Umbraco.Core/Models/Language.cs index 9299665755..2072533917 100644 --- a/src/Umbraco.Core/Models/Language.cs +++ b/src/Umbraco.Core/Models/Language.cs @@ -29,22 +29,14 @@ public class Language : EntityBase, ILanguage _cultureName = cultureName ?? throw new ArgumentNullException(nameof(cultureName)); } - [Obsolete( - "Use the constructor not requiring global settings and accepting an explicit name instead, scheduled for removal in V11.")] - public Language(GlobalSettings globalSettings, string isoCode) - { - _isoCode = isoCode ?? throw new ArgumentNullException(nameof(isoCode)); - _cultureName = CultureInfo.GetCultureInfo(isoCode).EnglishName; - } - - /// - [DataMember] - public string IsoCode - { - get => _isoCode; - set + /// + [DataMember] + public string IsoCode { - ArgumentNullException.ThrowIfNull(value); + get => _isoCode; + set + { + ArgumentNullException.ThrowIfNull(value); SetPropertyValueAndDetectChanges(value, ref _isoCode!, nameof(IsoCode)); } diff --git a/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs index 5829512648..5d35e3a32a 100644 --- a/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs +++ b/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs @@ -1,5 +1,4 @@ using System.Globalization; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration.Models; @@ -10,7 +9,6 @@ using Umbraco.Cms.Core.Models.ContentEditing; using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; -using Umbraco.Cms.Web.Common.DependencyInjection; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Models.Mapping; @@ -34,48 +32,12 @@ public class ContentTypeMapDefinition : IMapDefinition private readonly IShortStringHelper _shortStringHelper; private ContentSettings _contentSettings; - [Obsolete("Use ctor with all params injected")] - public ContentTypeMapDefinition( - CommonMapper commonMapper, - PropertyEditorCollection propertyEditors, - IDataTypeService dataTypeService, - IFileService fileService, - IContentTypeService contentTypeService, - IMediaTypeService mediaTypeService, + public ContentTypeMapDefinition(CommonMapper commonMapper, PropertyEditorCollection propertyEditors, + IDataTypeService dataTypeService, IFileService fileService, + IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, - ILoggerFactory loggerFactory, - IShortStringHelper shortStringHelper, - IOptions globalSettings, - IHostingEnvironment hostingEnvironment) - : this( - commonMapper, - propertyEditors, - dataTypeService, - fileService, - contentTypeService, - mediaTypeService, - memberTypeService, - loggerFactory, - shortStringHelper, - globalSettings, - hostingEnvironment, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } - - public ContentTypeMapDefinition( - CommonMapper commonMapper, - PropertyEditorCollection propertyEditors, - IDataTypeService dataTypeService, - IFileService fileService, - IContentTypeService contentTypeService, - IMediaTypeService mediaTypeService, - IMemberTypeService memberTypeService, - ILoggerFactory loggerFactory, - IShortStringHelper shortStringHelper, - IOptions globalSettings, - IHostingEnvironment hostingEnvironment, - IOptionsMonitor contentSettings) + ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IOptions globalSettings, + IHostingEnvironment hostingEnvironment, IOptionsMonitor contentSettings) { _commonMapper = commonMapper; _propertyEditors = propertyEditors; @@ -94,32 +56,6 @@ public class ContentTypeMapDefinition : IMapDefinition contentSettings.OnChange(x => _contentSettings = x); } - public static Udi? MapContentTypeUdi(IContentTypeComposition source) - { - if (source == null) - { - return null; - } - - string udiType; - switch (source) - { - case IMemberType _: - udiType = Constants.UdiEntityType.MemberType; - break; - case IMediaType _: - udiType = Constants.UdiEntityType.MediaType; - break; - case IContentType _: - udiType = Constants.UdiEntityType.DocumentType; - break; - default: - throw new PanicException($"Source is of type {source.GetType()} which isn't supported here"); - } - - return Udi.Create(udiType, source.Key); - } - public void DefineMaps(IUmbracoMapper mapper) { mapper.Define( @@ -171,7 +107,52 @@ public class ContentTypeMapDefinition : IMapDefinition (source, context) => new MemberPropertyTypeDisplay(), Map); } - private static void MapHistoryCleanup(DocumentTypeSave source, IContentTypeWithHistoryCleanup target) + public static Udi? MapContentTypeUdi(IContentTypeComposition source) + { + if (source == null) + { + return null; + } + + string udiType; + switch (source) + { + case IMemberType _: + udiType = Constants.UdiEntityType.MemberType; + break; + case IMediaType _: + udiType = Constants.UdiEntityType.MediaType; + break; + case IContentType _: + udiType = Constants.UdiEntityType.DocumentType; + break; + default: + throw new PanicException($"Source is of type {source.GetType()} which isn't supported here"); + } + + return Udi.Create(udiType, source.Key); + } + + // no MapAll - take care + private void Map(DocumentTypeSave source, IContentType target, MapperContext context) + { + MapSaveToTypeBase(source, target, context); + MapComposition(source, target, alias => _contentTypeService.Get(alias)); + + MapHistoryCleanup(source, target); + + target.AllowedTemplates = source.AllowedTemplates? + .Where(x => x != null) + .Select(_fileService.GetTemplate) + .WhereNotNull() + .ToArray(); + + target.SetDefaultTemplate(source.DefaultTemplate == null + ? null + : _fileService.GetTemplate(source.DefaultTemplate)); + } + + private static void MapHistoryCleanup(DocumentTypeSave source, IContentType target) { // If source history cleanup is null we don't have to map all properties if (source.HistoryCleanup is null) @@ -247,28 +228,6 @@ public class ContentTypeMapDefinition : IMapDefinition target.SortOrder = source.SortOrder; } - // no MapAll - take care - private void Map(DocumentTypeSave source, IContentType target, MapperContext context) - { - MapSaveToTypeBase(source, target, context); - MapComposition(source, target, alias => _contentTypeService.Get(alias)); - - if (target is IContentTypeWithHistoryCleanup targetWithHistoryCleanup) - { - MapHistoryCleanup(source, targetWithHistoryCleanup); - } - - target.AllowedTemplates = source.AllowedTemplates? - .Where(x => x != null) - .Select(_fileService.GetTemplate) - .WhereNotNull() - .ToArray(); - - target.SetDefaultTemplate(source.DefaultTemplate == null - ? null - : _fileService.GetTemplate(source.DefaultTemplate)); - } - // no MapAll - take care private void Map(MediaTypeSave source, IMediaType target, MapperContext context) { @@ -303,7 +262,7 @@ public class ContentTypeMapDefinition : IMapDefinition { MapTypeToDisplayBase(source, target); - if (source is IContentTypeWithHistoryCleanup sourceWithHistoryCleanup) + if (source is IContentType sourceWithHistoryCleanup) { target.HistoryCleanup = new HistoryCleanupViewModel { @@ -316,7 +275,7 @@ public class ContentTypeMapDefinition : IMapDefinition _contentSettings.ContentVersionCleanupPolicy.KeepAllVersionsNewerThanDays, GlobalKeepLatestVersionPerDayForDays = _contentSettings.ContentVersionCleanupPolicy.KeepLatestVersionPerDayForDays, - GlobalEnableCleanup = _contentSettings.ContentVersionCleanupPolicy.EnableCleanup, + GlobalEnableCleanup = _contentSettings.ContentVersionCleanupPolicy.EnableCleanup }; } @@ -495,7 +454,8 @@ public class ContentTypeMapDefinition : IMapDefinition source, target, context); // Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes - private static void Map(PropertyGroupBasic source, PropertyGroup target, MapperContext context) + private static void Map(PropertyGroupBasic source, PropertyGroup target, + MapperContext context) { if (source.Id > 0) { @@ -936,7 +896,8 @@ public class ContentTypeMapDefinition : IMapDefinition } } - private static void MapComposition(ContentTypeSave source, IContentTypeComposition target, Func getContentType) + private static void MapComposition(ContentTypeSave source, IContentTypeComposition target, + Func getContentType) { var current = target.CompositionAliases().ToArray(); IEnumerable proposed = source.CompositeContentTypes; diff --git a/src/Umbraco.Core/Models/Mapping/DictionaryMapDefinition.cs b/src/Umbraco.Core/Models/Mapping/DictionaryMapDefinition.cs index e1550971e1..3c79d1c12f 100644 --- a/src/Umbraco.Core/Models/Mapping/DictionaryMapDefinition.cs +++ b/src/Umbraco.Core/Models/Mapping/DictionaryMapDefinition.cs @@ -15,11 +15,6 @@ public class DictionaryMapDefinition : IMapDefinition private readonly CommonMapper? _commonMapper; private readonly ILocalizationService _localizationService; - [Obsolete("Use the constructor with the CommonMapper")] - public DictionaryMapDefinition(ILocalizationService localizationService) : this(localizationService, StaticServiceProvider.Instance.GetRequiredService()) - { - } - public DictionaryMapDefinition(ILocalizationService localizationService, CommonMapper commonMapper) { _localizationService = localizationService; @@ -30,9 +25,7 @@ public class DictionaryMapDefinition : IMapDefinition { mapper.Define((source, context) => new EntityBasic(), Map); mapper.Define((source, context) => new DictionaryDisplay(), Map); - mapper.Define( - (source, context) => new DictionaryOverviewDisplay(), - Map); + mapper.Define((source, context) => new DictionaryOverviewDisplay(), Map); } // Umbraco.Code.MapAll -ParentId -Path -Trashed -Udi -Icon diff --git a/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs b/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs index ae9876628f..65db6181dd 100644 --- a/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs +++ b/src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs @@ -70,7 +70,8 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper return resolved; } - [Obsolete("Use MapMembershipProperties. Will be removed in Umbraco 10.")] + // We need this because we call GetCustomGenericProperties from TabsAndPropertiesMapper + // and we have no access to MapMembershipProperties from the base class without casting protected override IEnumerable GetCustomGenericProperties(IContentBase content) { var member = (IMember)content; diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index bd5e7af0a4..aeee722ed2 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -56,21 +56,6 @@ namespace Umbraco.Cms.Core.Models.PublishedContent InitializeIndexes(); } - [Obsolete("Use the overload specifying a key instead")] - public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations, bool isElement = false) - : this (Guid.Empty, id, alias, itemType, compositionAliases, variations, isElement) - { - PublishedPropertyType[] propertyTypesA = propertyTypes.ToArray(); - foreach (PublishedPropertyType propertyType in propertyTypesA) - { - propertyType.ContentType = this; - } - - _propertyTypes = propertyTypesA; - - InitializeIndexes(); - } - /// /// This constructor is for tests and is not intended to be used directly from application code. /// @@ -85,15 +70,6 @@ namespace Umbraco.Cms.Core.Models.PublishedContent InitializeIndexes(); } - [Obsolete("Use the overload specifying a key instead")] - public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, Func> propertyTypes, ContentVariation variations, bool isElement = false) - : this(Guid.Empty, id, alias, itemType, compositionAliases, variations, isElement) - { - _propertyTypes = propertyTypes(this).ToArray(); - - InitializeIndexes(); - } - private PublishedContentType(Guid key, int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, ContentVariation variations, bool isElement) { Key = key; diff --git a/src/Umbraco.Core/Models/RelationType.cs b/src/Umbraco.Core/Models/RelationType.cs index d48e802c6e..519885b7fa 100644 --- a/src/Umbraco.Core/Models/RelationType.cs +++ b/src/Umbraco.Core/Models/RelationType.cs @@ -1,4 +1,4 @@ -using System.Runtime.Serialization; +using System.Runtime.Serialization; using Umbraco.Cms.Core.Models.Entities; namespace Umbraco.Cms.Core.Models; @@ -22,14 +22,7 @@ public class RelationType : EntityBase, IRelationTypeWithIsDependency { } - [Obsolete("Use ctor with isDependency parameter")] - public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType) - : this(name, alias, isBidrectional, parentObjectType, childObjectType, false) - { - } - - public RelationType(string? name, string? alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType, bool isDependency) - { + public RelationType(string? name, string? alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType, bool isDependency){ if (name == null) { throw new ArgumentNullException(nameof(name)); diff --git a/src/Umbraco.Core/Models/SendCodeViewModel.cs b/src/Umbraco.Core/Models/SendCodeViewModel.cs index c73fd73eb3..29d318f8ff 100644 --- a/src/Umbraco.Core/Models/SendCodeViewModel.cs +++ b/src/Umbraco.Core/Models/SendCodeViewModel.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; namespace Umbraco.Cms.Core.Models; @@ -11,11 +11,11 @@ public class Verify2FACodeModel { [Required] [DataMember(Name = "code", IsRequired = true)] - public string? Code { get; set; } + public required string Code { get; set; } [Required] [DataMember(Name = "provider", IsRequired = true)] - public string? Provider { get; set; } + public required string Provider { get; set; } /// /// Flag indicating whether the sign-in cookie should persist after the browser is closed. diff --git a/src/Umbraco.Core/Models/SetPasswordModel.cs b/src/Umbraco.Core/Models/SetPasswordModel.cs index 57d1abc38f..58803c101d 100644 --- a/src/Umbraco.Core/Models/SetPasswordModel.cs +++ b/src/Umbraco.Core/Models/SetPasswordModel.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; namespace Umbraco.Cms.Core.Models; @@ -12,9 +12,9 @@ public class SetPasswordModel [Required] [DataMember(Name = "password", IsRequired = true)] - public string? Password { get; set; } + public required string Password { get; set; } [Required] [DataMember(Name = "resetCode", IsRequired = true)] - public string? ResetCode { get; set; } + public required string ResetCode { get; set; } } diff --git a/src/Umbraco.Core/Models/UnLinkLoginModel.cs b/src/Umbraco.Core/Models/UnLinkLoginModel.cs index c121230810..ba4d881b73 100644 --- a/src/Umbraco.Core/Models/UnLinkLoginModel.cs +++ b/src/Umbraco.Core/Models/UnLinkLoginModel.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; namespace Umbraco.Cms.Core.Models; @@ -7,9 +7,9 @@ public class UnLinkLoginModel { [Required] [DataMember(Name = "loginProvider", IsRequired = true)] - public string? LoginProvider { get; set; } + public required string LoginProvider { get; set; } [Required] [DataMember(Name = "providerKey", IsRequired = true)] - public string? ProviderKey { get; set; } + public required string ProviderKey { get; set; } } diff --git a/src/Umbraco.Core/Notifications/UmbracoApplicationComponentsInstallingNotification.cs b/src/Umbraco.Core/Notifications/UmbracoApplicationComponentsInstallingNotification.cs deleted file mode 100644 index 036d5cf8a4..0000000000 --- a/src/Umbraco.Core/Notifications/UmbracoApplicationComponentsInstallingNotification.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -namespace Umbraco.Cms.Core.Notifications; - -// TODO (V10): Remove this class. - -/// -/// Notification that occurs during the Umbraco boot process, before instances of initialize. -/// -[Obsolete( - "This notification was added to the core runtime start-up as a hook for Umbraco Cloud local connection string and database setup. " + - "Following re-work they are no longer used (from Deploy 9.2.0)." + - "Given they are non-documented and no other use is expected, they can be removed in the next major release")] -public class UmbracoApplicationComponentsInstallingNotification : INotification -{ - /// - /// Initializes a new instance of the class. - /// - /// The runtime level - public UmbracoApplicationComponentsInstallingNotification(RuntimeLevel runtimeLevel) => RuntimeLevel = runtimeLevel; - - /// - /// Gets the runtime level of execution. - /// - public RuntimeLevel RuntimeLevel { get; } -} diff --git a/src/Umbraco.Core/Notifications/UmbracoApplicationMainDomAcquiredNotification.cs b/src/Umbraco.Core/Notifications/UmbracoApplicationMainDomAcquiredNotification.cs deleted file mode 100644 index 2bbab6e7ec..0000000000 --- a/src/Umbraco.Core/Notifications/UmbracoApplicationMainDomAcquiredNotification.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -namespace Umbraco.Cms.Core.Notifications; - -// TODO (V10): Remove this class. - -/// -/// Notification that occurs during Umbraco boot after the MainDom has been acquired. -/// -[Obsolete( - "This notification was added to the core runtime start-up as a hook for Umbraco Cloud local connection string and database setup. " + - "Following re-work they are no longer used (from Deploy 9.2.0)." + - "Given they are non-documented and no other use is expected, they can be removed in the next major release")] -public class UmbracoApplicationMainDomAcquiredNotification : INotification -{ - /// - /// Initializes a new instance of the class. - /// - public UmbracoApplicationMainDomAcquiredNotification() - { - } -} diff --git a/src/Umbraco.Core/Notifications/UmbracoApplicationStartingNotification.cs b/src/Umbraco.Core/Notifications/UmbracoApplicationStartingNotification.cs index 7c7e97f29f..49eaac02f2 100644 --- a/src/Umbraco.Core/Notifications/UmbracoApplicationStartingNotification.cs +++ b/src/Umbraco.Core/Notifications/UmbracoApplicationStartingNotification.cs @@ -2,32 +2,21 @@ namespace Umbraco.Cms.Core.Notifications; /// /// Notification that occurs at the very end of the Umbraco boot process (after all s are -/// initialized). -/// -/// -public class UmbracoApplicationStartingNotification : IUmbracoApplicationLifetimeNotification -{ - /// - /// Initializes a new instance of the class. +/// initialized). /// - /// The runtime level - [Obsolete("Use ctor with all params")] - public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel) - : this(runtimeLevel, false) + /// + public class UmbracoApplicationStartingNotification : IUmbracoApplicationLifetimeNotification { - // TODO: Remove this constructor in V10 - } - - /// - /// Initializes a new instance of the class. - /// - /// The runtime level - /// Indicates whether Umbraco is restarting. - public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel, bool isRestarting) - { - RuntimeLevel = runtimeLevel; - IsRestarting = isRestarting; - } + /// + /// Initializes a new instance of the class. + /// + /// The runtime level + /// Indicates whether Umbraco is restarting. + public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel, bool isRestarting) + { + RuntimeLevel = runtimeLevel; + IsRestarting = isRestarting; + } /// /// Gets the runtime level. diff --git a/src/Umbraco.Core/Notifications/UmbracoApplicationStoppingNotification.cs b/src/Umbraco.Core/Notifications/UmbracoApplicationStoppingNotification.cs index a877bd3162..8face75954 100644 --- a/src/Umbraco.Core/Notifications/UmbracoApplicationStoppingNotification.cs +++ b/src/Umbraco.Core/Notifications/UmbracoApplicationStoppingNotification.cs @@ -1,26 +1,17 @@ namespace Umbraco.Cms.Core.Notifications; -/// -/// Notification that occurs when Umbraco is shutting down (after all s are terminated). -/// -/// -public class UmbracoApplicationStoppingNotification : IUmbracoApplicationLifetimeNotification -{ - /// - /// Initializes a new instance of the class. - /// - [Obsolete("Use ctor with all params")] - public UmbracoApplicationStoppingNotification() - : this(false) - { - // TODO: Remove this constructor in V10 - } /// - /// Initializes a new instance of the class. + /// Notification that occurs when Umbraco is shutting down (after all s are terminated). /// - /// Indicates whether Umbraco is restarting. - public UmbracoApplicationStoppingNotification(bool isRestarting) => IsRestarting = isRestarting; + /// + public class UmbracoApplicationStoppingNotification : IUmbracoApplicationLifetimeNotification + { + /// + /// Initializes a new instance of the class. + /// + /// Indicates whether Umbraco is restarting. + public UmbracoApplicationStoppingNotification(bool isRestarting) => IsRestarting = isRestarting; /// public bool IsRestarting { get; } diff --git a/src/Umbraco.Core/Persistence/Repositories/IExternalLoginRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IExternalLoginRepository.cs deleted file mode 100644 index 6d7370768c..0000000000 --- a/src/Umbraco.Core/Persistence/Repositories/IExternalLoginRepository.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Umbraco.Cms.Core.Security; - -namespace Umbraco.Cms.Core.Persistence.Repositories; - -public interface IExternalLoginRepository : IReadWriteQueryRepository, - IQueryRepository -{ - /// - /// Replaces all external login providers for the user - /// - /// - /// - [Obsolete("Use method that takes guid as param from IExternalLoginWithKeyRepository")] - void Save(int userId, IEnumerable logins); - - /// - /// Replaces all external login provider tokens for the providers specified for the user - /// - /// - /// - [Obsolete("Use method that takes guid as param from IExternalLoginWithKeyRepository")] - void Save(int userId, IEnumerable tokens); - - [Obsolete("Use method that takes guid as param from IExternalLoginWithKeyRepository")] - void DeleteUserLogins(int memberId); -} diff --git a/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs index 9d2fe0ecbf..136abec3c4 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs @@ -1,8 +1,11 @@ -using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.Persistence.Repositories; public interface IMacroRepository : IReadWriteQueryRepository, IReadRepository { - // IEnumerable GetAll(params string[] aliases); + IMacro? GetByAlias(string alias); + + IEnumerable GetAllByAlias(string[] aliases); + } diff --git a/src/Umbraco.Core/Persistence/Repositories/IMacroWithAliasRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMacroWithAliasRepository.cs deleted file mode 100644 index 48ead78759..0000000000 --- a/src/Umbraco.Core/Persistence/Repositories/IMacroWithAliasRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Umbraco.Cms.Core.Models; - -namespace Umbraco.Cms.Core.Persistence.Repositories; - -[Obsolete("This interface will be merged with IMacroRepository in Umbraco 11")] -public interface IMacroWithAliasRepository : IMacroRepository -{ - IMacro? GetByAlias(string alias); - - IEnumerable GetAllByAlias(string[] aliases); -} diff --git a/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs index 58475f802d..32c04bdb4b 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IMemberRepository.cs @@ -38,20 +38,4 @@ public interface IMemberRepository : IContentRepository /// /// int GetCountByQuery(IQuery? query); - - /// - /// Sets a members last login date based on their username - /// - /// - /// - /// - /// This is a specialized method because whenever a member logs in, the membership provider requires us to set the - /// 'online' which requires - /// updating their login date. This operation must be fast and cannot use database locks which is fine if we are only - /// executing a single query - /// for this data since there won't be any other data contention issues. - /// - [Obsolete( - "This is now a NoOp since last login date is no longer an umbraco property, set the date on the IMember directly and Save it instead, scheduled for removal in V11.")] - void SetLastLogin(string username, DateTime date); } diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs index 893a3c248e..35458d6eba 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs @@ -1,4 +1,4 @@ -using System.Linq.Expressions; +using System.Linq.Expressions; using Umbraco.Cms.Core.Models.Membership; using Umbraco.Cms.Core.Persistence.Querying; @@ -13,14 +13,6 @@ public interface IUserRepository : IReadWriteQueryRepository /// int GetCountByQuery(IQuery? query); - /// - /// Checks if a user with the username exists - /// - /// - /// - [Obsolete("This method will be removed in future versions. Please use ExistsByUserName instead.")] - bool Exists(string username); - /// /// Checks if a user with the username exists /// diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index d73eb5a2eb..2e26894d23 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -1,4 +1,4 @@ -using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Models.PublishedContent; namespace Umbraco.Cms.Core.PropertyEditors; diff --git a/src/Umbraco.Core/Routing/DefaultUrlProvider.cs b/src/Umbraco.Core/Routing/DefaultUrlProvider.cs index d0a238dbb2..6506d29725 100644 --- a/src/Umbraco.Core/Routing/DefaultUrlProvider.cs +++ b/src/Umbraco.Core/Routing/DefaultUrlProvider.cs @@ -24,37 +24,20 @@ public class DefaultUrlProvider : IUrlProvider private readonly UriUtility _uriUtility; private RequestHandlerSettings _requestSettings; - [Obsolete("Use ctor with all parameters")] - public DefaultUrlProvider( - IOptionsMonitor requestSettings, - ILogger logger, - ISiteDomainMapper siteDomainMapper, - IUmbracoContextAccessor umbracoContextAccessor, - UriUtility uriUtility) - : this( - requestSettings, - logger, - siteDomainMapper, - umbracoContextAccessor, - uriUtility, - StaticServiceProvider.Instance.GetRequiredService()) - { - } - - public DefaultUrlProvider( - IOptionsMonitor requestSettings, - ILogger logger, - ISiteDomainMapper siteDomainMapper, - IUmbracoContextAccessor umbracoContextAccessor, - UriUtility uriUtility, - ILocalizationService localizationService) - { - _requestSettings = requestSettings.CurrentValue; - _logger = logger; - _siteDomainMapper = siteDomainMapper; - _umbracoContextAccessor = umbracoContextAccessor; - _uriUtility = uriUtility; - _localizationService = localizationService; + public DefaultUrlProvider( + IOptionsMonitor requestSettings, + ILogger logger, + ISiteDomainMapper siteDomainMapper, + IUmbracoContextAccessor umbracoContextAccessor, + UriUtility uriUtility, + ILocalizationService localizationService) + { + _requestSettings = requestSettings.CurrentValue; + _logger = logger; + _siteDomainMapper = siteDomainMapper; + _umbracoContextAccessor = umbracoContextAccessor; + _uriUtility = uriUtility; + _localizationService = localizationService; requestSettings.OnChange(x => _requestSettings = x); } diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index 0a744f3f0f..60ad1f10ba 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -539,7 +539,7 @@ internal class EntityXmlSerializer : IEntityXmlSerializer genericProperties, tabs); - if (contentType is IContentTypeWithHistoryCleanup withCleanup && withCleanup.HistoryCleanup is not null) + if (contentType is IContentType withCleanup && withCleanup.HistoryCleanup is not null) { xml.Add(SerializeCleanupPolicy(withCleanup.HistoryCleanup)); } diff --git a/src/Umbraco.Core/Services/ExternalLoginService.cs b/src/Umbraco.Core/Services/ExternalLoginService.cs index 677108dbcd..061e0b93aa 100644 --- a/src/Umbraco.Core/Services/ExternalLoginService.cs +++ b/src/Umbraco.Core/Services/ExternalLoginService.cs @@ -9,7 +9,7 @@ using Umbraco.Extensions; namespace Umbraco.Cms.Core.Services; -public class ExternalLoginService : RepositoryService, IExternalLoginService, IExternalLoginWithKeyService +public class ExternalLoginService : RepositoryService, IExternalLoginWithKeyService { private readonly IExternalLoginWithKeyRepository _externalLoginRepository; @@ -21,37 +21,6 @@ public class ExternalLoginService : RepositoryService, IExternalLoginService, IE : base(provider, loggerFactory, eventMessagesFactory) => _externalLoginRepository = externalLoginRepository; - [Obsolete("Use ctor injecting IExternalLoginWithKeyRepository")] - public ExternalLoginService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IExternalLoginRepository externalLoginRepository) - : this(provider, loggerFactory, eventMessagesFactory, StaticServiceProvider.Instance.GetRequiredService()) - { - } - - /// - [Obsolete("Use overload that takes a user/member key (Guid).")] - public IEnumerable GetExternalLogins(int userId) - => GetExternalLogins(userId.ToGuid()); - - /// - [Obsolete("Use overload that takes a user/member key (Guid).")] - public IEnumerable GetExternalLoginTokens(int userId) => - GetExternalLoginTokens(userId.ToGuid()); - - /// - [Obsolete("Use overload that takes a user/member key (Guid).")] - public void Save(int userId, IEnumerable logins) - => Save(userId.ToGuid(), logins); - - /// - [Obsolete("Use overload that takes a user/member key (Guid).")] - public void Save(int userId, IEnumerable tokens) - => Save(userId.ToGuid(), tokens); - - /// - [Obsolete("Use overload that takes a user/member key (Guid).")] - public void DeleteUserLogins(int userId) - => DeleteUserLogins(userId.ToGuid()); - public IEnumerable Find(string loginProvider, string providerKey) { using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true)) diff --git a/src/Umbraco.Core/Services/IExternalLoginService.cs b/src/Umbraco.Core/Services/IExternalLoginService.cs deleted file mode 100644 index ba75d505ff..0000000000 --- a/src/Umbraco.Core/Services/IExternalLoginService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Umbraco.Cms.Core.Security; - -namespace Umbraco.Cms.Core.Services; - -/// -/// Used to store the external login info -/// -[Obsolete("Use IExternalLoginServiceWithKey. This will be removed in Umbraco 10")] -public interface IExternalLoginService : IService -{ - /// - /// Returns all user logins assigned - /// - /// - /// - IEnumerable GetExternalLogins(int userId); - - /// - /// Returns all user login tokens assigned - /// - /// - /// - IEnumerable GetExternalLoginTokens(int userId); - - /// - /// Returns all logins matching the login info - generally there should only be one but in some cases - /// there might be more than one depending on if an administrator has been editing/removing members - /// - /// - /// - /// - IEnumerable Find(string loginProvider, string providerKey); - - /// - /// Saves the external logins associated with the user - /// - /// - /// The user associated with the logins - /// - /// - /// - /// This will replace all external login provider information for the user - /// - void Save(int userId, IEnumerable logins); - - /// - /// Saves the external login tokens associated with the user - /// - /// - /// The user associated with the tokens - /// - /// - /// - /// This will replace all external login tokens for the user - /// - void Save(int userId, IEnumerable tokens); - - /// - /// Deletes all user logins - normally used when a member is deleted - /// - /// - void DeleteUserLogins(int userId); -} diff --git a/src/Umbraco.Core/Services/IMacroService.cs b/src/Umbraco.Core/Services/IMacroService.cs index 141b278d93..ef99248727 100644 --- a/src/Umbraco.Core/Services/IMacroService.cs +++ b/src/Umbraco.Core/Services/IMacroService.cs @@ -49,5 +49,12 @@ public interface IMacroService : IService ///// ///// Alias to retrieve an for ///// An object - // IMacroPropertyType GetMacroPropertyTypeByAlias(string alias); + //IMacroPropertyType GetMacroPropertyTypeByAlias(string alias); + + /// + /// Gets a list of available objects by alias. + /// + /// Optional array of aliases to limit the results + /// An enumerable list of objects + IEnumerable GetAll(params string[] aliases); } diff --git a/src/Umbraco.Core/Services/IMacroWithAliasService.cs b/src/Umbraco.Core/Services/IMacroWithAliasService.cs deleted file mode 100644 index 508168b877..0000000000 --- a/src/Umbraco.Core/Services/IMacroWithAliasService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Umbraco.Cms.Core.Models; - -namespace Umbraco.Cms.Core.Services; - -[Obsolete("This interface will be merged with IMacroService in Umbraco 11")] -public interface IMacroWithAliasService : IMacroService -{ - /// - /// Gets a list of available objects by alias. - /// - /// Optional array of aliases to limit the results - /// An enumerable list of objects - IEnumerable GetAll(params string[] aliases); -} diff --git a/src/Umbraco.Core/Services/IMembershipMemberService.cs b/src/Umbraco.Core/Services/IMembershipMemberService.cs index dc96535f8b..553441f572 100644 --- a/src/Umbraco.Core/Services/IMembershipMemberService.cs +++ b/src/Umbraco.Core/Services/IMembershipMemberService.cs @@ -128,20 +128,6 @@ public interface IMembershipMemberService : IService /// or to Delete void Delete(T membershipUser); - /// - /// Sets the last login date for the member if they are found by username - /// - /// - /// - /// - /// This is a specialized method because whenever a member logs in, the membership provider requires us to set the - /// 'online' which requires - /// updating their login date. This operation must be fast and cannot use database locks which is fine if we are only - /// executing a single query - /// for this data since there won't be any other data contention issues. - /// - void SetLastLogin(string username, DateTime date); - /// /// Saves an /// diff --git a/src/Umbraco.Core/Services/ITwoFactorLoginService.cs b/src/Umbraco.Core/Services/ITwoFactorLoginService.cs index d0509a9283..0a0cc751d5 100644 --- a/src/Umbraco.Core/Services/ITwoFactorLoginService.cs +++ b/src/Umbraco.Core/Services/ITwoFactorLoginService.cs @@ -52,15 +52,17 @@ public interface ITwoFactorLoginService : IService Task SaveAsync(TwoFactorLogin twoFactorLogin); /// - /// Gets all the enabled 2FA providers for the user or member with the specified key. + /// Gets all the enabled 2FA providers for the user or member with the specified key. /// Task> GetEnabledTwoFactorProviderNamesAsync(Guid userOrMemberKey); -} -[Obsolete("This will be merged into ITwoFactorLoginService in Umbraco 11")] -public interface ITwoFactorLoginService2 : ITwoFactorLoginService -{ + /// + /// Disables 2FA with Code. + /// Task DisableWithCodeAsync(string providerName, Guid userOrMemberKey, string code); + /// + /// Validates and Saves. + /// Task ValidateAndSaveAsync(string providerName, Guid userKey, string secret, string code); } diff --git a/src/Umbraco.Core/Services/LocalizedTextService.cs b/src/Umbraco.Core/Services/LocalizedTextService.cs index 839e52f49e..1634f60baa 100644 --- a/src/Umbraco.Core/Services/LocalizedTextService.cs +++ b/src/Umbraco.Core/Services/LocalizedTextService.cs @@ -64,27 +64,16 @@ public class LocalizedTextService : ILocalizedTextService XmlSourceToNoAreaDictionary(source)); } - [Obsolete( - "Use other ctor with IDictionary>>> as input parameter.")] - public LocalizedTextService( - IDictionary>> source, - ILogger logger) - : this( - source.ToDictionary(x => x.Key, x => new Lazy>>(() => x.Value)), - logger) - { - } - - /// - /// Initializes with a source of a dictionary of culture -> areas -> sub dictionary of keys/values - /// - /// - /// - public LocalizedTextService( - IDictionary>>> source, - ILogger logger) - { - IDictionary>>> dictionarySource = + /// + /// Initializes with a source of a dictionary of culture -> areas -> sub dictionary of keys/values + /// + /// + /// + public LocalizedTextService( + IDictionary>>> source, + ILogger logger) + { + IDictionary>>> dictionarySource = source ?? throw new ArgumentNullException(nameof(source)); _dictionarySourceLazy = new Lazy>>>>(() => diff --git a/src/Umbraco.Core/Services/MacroService.cs b/src/Umbraco.Core/Services/MacroService.cs index 73889895e2..be07d1ef02 100644 --- a/src/Umbraco.Core/Services/MacroService.cs +++ b/src/Umbraco.Core/Services/MacroService.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Notifications; @@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Services; /// /// Represents the Macro Service, which is an easy access to operations involving /// -internal class MacroService : RepositoryService, IMacroWithAliasService +internal class MacroService : RepositoryService, IMacroService { private readonly IAuditRepository _auditRepository; private readonly IMacroRepository _macroRepository; @@ -34,7 +34,7 @@ internal class MacroService : RepositoryService, IMacroWithAliasService /// An object public IMacro? GetByAlias(string alias) { - if (_macroRepository is not IMacroWithAliasRepository macroWithAliasRepository) + if (_macroRepository is not IMacroRepository macroWithAliasRepository) { return GetAll().FirstOrDefault(x => x.Alias == alias); } @@ -65,7 +65,7 @@ internal class MacroService : RepositoryService, IMacroWithAliasService public IEnumerable GetAll(params string[] aliases) { - if (_macroRepository is not IMacroWithAliasRepository macroWithAliasRepository) + if (_macroRepository is not IMacroRepository macroWithAliasRepository) { var hashset = new HashSet(aliases); return GetAll().Where(x => hashset.Contains(x.Alias)); diff --git a/src/Umbraco.Core/Services/MemberService.cs b/src/Umbraco.Core/Services/MemberService.cs index 76d730dc78..d8f9f787aa 100644 --- a/src/Umbraco.Core/Services/MemberService.cs +++ b/src/Umbraco.Core/Services/MemberService.cs @@ -728,11 +728,7 @@ namespace Umbraco.Cms.Core.Services #region Save - /// - [Obsolete("This is now a NoOp since last login date is no longer an umbraco property, set the date on the IMember directly and Save it instead, scheduled for removal in V11.")] - public void SetLastLogin(string username, DateTime date) - { - } + public void SetLastLogin(string username, DateTime date) => throw new NotImplementedException(); /// public void Save(IMember member) diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Core/Services/ServiceContext.cs index 0e24f27be5..9def2bd8fa 100644 --- a/src/Umbraco.Core/Services/ServiceContext.cs +++ b/src/Umbraco.Core/Services/ServiceContext.cs @@ -1,4 +1,4 @@ -namespace Umbraco.Cms.Core.Services; +namespace Umbraco.Cms.Core.Services; /// /// Represents the Umbraco Service context, which provides access to all services. @@ -13,7 +13,7 @@ public class ServiceContext private readonly Lazy? _dataTypeService; private readonly Lazy? _domainService; private readonly Lazy? _entityService; - private readonly Lazy? _externalLoginService; + private readonly Lazy? _externalLoginService; private readonly Lazy? _fileService; private readonly Lazy? _keyValueService; private readonly Lazy? _localizationService; @@ -59,7 +59,7 @@ public class ServiceContext Lazy? memberTypeService, Lazy? memberGroupService, Lazy? notificationService, - Lazy? externalLoginService, + Lazy? externalLoginService, Lazy? redirectUrlService, Lazy? consentService, Lazy? keyValueService, @@ -207,7 +207,7 @@ public class ServiceContext /// /// Gets the ExternalLoginService. /// - public IExternalLoginService? ExternalLoginService => _externalLoginService?.Value; + public IExternalLoginWithKeyService? ExternalLoginService => _externalLoginService?.Value; /// /// Gets the RedirectUrlService. @@ -257,7 +257,7 @@ public class ServiceContext IDomainService? domainService = null, IMacroService? macroService = null, IPublicAccessService? publicAccessService = null, - IExternalLoginService? externalLoginService = null, + IExternalLoginWithKeyService? externalLoginService = null, IServerRegistrationService? serverRegistrationService = null, IRedirectUrlService? redirectUrlService = null, IConsentService? consentService = null, diff --git a/src/Umbraco.Core/Services/TwoFactorLoginService.cs b/src/Umbraco.Core/Services/TwoFactorLoginService.cs index de79284ac9..acbdded1c9 100644 --- a/src/Umbraco.Core/Services/TwoFactorLoginService.cs +++ b/src/Umbraco.Core/Services/TwoFactorLoginService.cs @@ -11,7 +11,7 @@ using Umbraco.Cms.Web.Common.DependencyInjection; namespace Umbraco.Cms.Core.Services; /// -public class TwoFactorLoginService : ITwoFactorLoginService2 +public class TwoFactorLoginService : ITwoFactorLoginService { private readonly IOptions _backOfficeIdentityOptions; private readonly IOptions _identityOptions; @@ -39,23 +39,6 @@ public class TwoFactorLoginService : ITwoFactorLoginService2 _twoFactorSetupGenerators = twoFactorSetupGenerators.ToDictionary(x => x.ProviderName); } - [Obsolete("Use ctor with all params - This will be removed in v11")] - public TwoFactorLoginService( - ITwoFactorLoginRepository twoFactorLoginRepository, - ICoreScopeProvider scopeProvider, - IEnumerable twoFactorSetupGenerators, - IOptions identityOptions, - IOptions backOfficeIdentityOptions) - : this( - twoFactorLoginRepository, - scopeProvider, - twoFactorSetupGenerators, - identityOptions, - backOfficeIdentityOptions, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } - /// public async Task DeleteUserLoginsAsync(Guid userOrMemberKey) { diff --git a/src/Umbraco.Core/Services/UserService.cs b/src/Umbraco.Core/Services/UserService.cs index 88e2708b2c..69e6351fbd 100644 --- a/src/Umbraco.Core/Services/UserService.cs +++ b/src/Umbraco.Core/Services/UserService.cs @@ -333,13 +333,8 @@ internal class UserService : RepositoryService, IUserService } } - // explicit implementation because we don't need it now but due to the way that the members membership provider is put together - // this method must exist in this service as an implementation (legacy) - void IMembershipMemberService.SetLastLogin(string username, DateTime date) => _logger.LogWarning( - "This method is not implemented. Using membership providers users is not advised, use ASP.NET Identity instead. See issue #9224 for more information."); - /// - /// Saves an + /// Saves an /// /// to Save public void Save(IUser entity) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 01183739d5..8ee0b780b0 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 Umbraco.Cms.Core Umbraco CMS Umbraco.Cms.Core @@ -15,6 +15,15 @@ + + + + + + + + + @@ -30,7 +39,7 @@ - + all diff --git a/src/Umbraco.Core/Web/IRequestAccessor.cs b/src/Umbraco.Core/Web/IRequestAccessor.cs index a72ec5bc72..57940b3c1b 100644 --- a/src/Umbraco.Core/Web/IRequestAccessor.cs +++ b/src/Umbraco.Core/Web/IRequestAccessor.cs @@ -5,12 +5,12 @@ public interface IRequestAccessor /// /// Returns the request/form/querystring value for the given name /// - string GetRequestValue(string name); + string? GetRequestValue(string name); /// /// Returns the query string value for the given name /// - string GetQueryStringValue(string name); + string? GetQueryStringValue(string name); /// /// Returns the current request uri diff --git a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs index c6116e122f..813618738b 100644 --- a/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs +++ b/src/Umbraco.Core/WebAssets/IRuntimeMinifier.cs @@ -1,34 +1,34 @@ namespace Umbraco.Cms.Core.WebAssets; /// -/// Used for bundling and minifying web assets at runtime +/// Used for bundling and minifying web assets at runtime /// public interface IRuntimeMinifier { /// - /// Returns the cache buster value + /// Returns the cache buster value /// string CacheBuster { get; } /// - /// Creates a css bundle + /// Creates a css bundle /// /// /// /// - /// All files must be absolute paths, relative paths will throw + /// All files must be absolute paths, relative paths will throw /// /// - /// Thrown if any of the paths specified are not absolute + /// Thrown if any of the paths specified are not absolute /// void CreateCssBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths); /// - /// Renders the html link tag for the bundle + /// Renders the html link tag for the bundle /// /// /// - /// An html encoded string + /// An html encoded string /// Task RenderCssHereAsync(string bundleName); @@ -39,63 +39,45 @@ public interface IRuntimeMinifier /// /// /// - /// All files must be absolute paths, relative paths will throw + /// All files must be absolute paths, relative paths will throw /// /// - /// Thrown if any of the paths specified are not absolute + /// Thrown if any of the paths specified are not absolute /// void CreateJsBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths); /// - /// Renders the html script tag for the bundle + /// Renders the html script tag for the bundle /// /// /// - /// An html encoded string + /// An html encoded string /// Task RenderJsHereAsync(string bundleName); /// - /// Returns the asset paths for the JS bundle name + /// Returns the asset paths for the JS bundle name /// /// /// - /// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL + /// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL /// Task> GetJsAssetPathsAsync(string bundleName); /// - /// Returns the asset paths for the css bundle name + /// Returns the asset paths for the css bundle name /// /// /// - /// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL + /// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL /// Task> GetCssAssetPathsAsync(string bundleName); /// - /// Minify the file content, of a given type + /// Minify the file content, of a given type /// /// /// /// Task MinifyAsync(string? fileContent, AssetType assetType); - - /// - /// Ensures that all runtime minifications are refreshed on next request. E.g. Clearing cache. - /// - /// - /// - /// No longer necessary, invalidation occurs automatically if any of the following occur. - /// - /// - /// Your sites assembly information version changes. - /// Umbraco.Cms.Core assembly information version changes. - /// RuntimeMinificationSettings Version string changes. - /// - /// for further - /// details. - /// - [Obsolete("Invalidation is handled automatically. Scheduled for removal V11.")] - void Reset(); } diff --git a/src/Umbraco.Examine.Lucene/DependencyInjection/ConfigureIndexOptions.cs b/src/Umbraco.Examine.Lucene/DependencyInjection/ConfigureIndexOptions.cs index e6306ab444..f7c3cf9a3e 100644 --- a/src/Umbraco.Examine.Lucene/DependencyInjection/ConfigureIndexOptions.cs +++ b/src/Umbraco.Examine.Lucene/DependencyInjection/ConfigureIndexOptions.cs @@ -25,7 +25,7 @@ public sealed class ConfigureIndexOptions : IConfigureNamedOptions - net6.0 + net7.0 Umbraco.Cms.Infrastructure.Examine Umbraco CMS Umbraco.Examine.Lucene diff --git a/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs b/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs index 6d583151ba..1e17b959b6 100644 --- a/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs +++ b/src/Umbraco.Infrastructure/Configuration/JsonConfigManipulator.cs @@ -19,11 +19,6 @@ namespace Umbraco.Cms.Core.Configuration private readonly ILogger _logger; private readonly object _locker = new object(); - [Obsolete] - public JsonConfigManipulator(IConfiguration configuration) - : this(configuration, StaticServiceProvider.Instance.GetRequiredService>()) - { } - public JsonConfigManipulator(IConfiguration configuration, ILogger logger) { _configuration = configuration; @@ -234,7 +229,7 @@ namespace Umbraco.Cms.Core.Configuration { if (provider.Source.FileProvider is PhysicalFileProvider physicalFileProvider) { - var jsonFilePath = Path.Combine(physicalFileProvider.Root, provider.Source.Path); + var jsonFilePath = Path.Combine(physicalFileProvider.Root, provider.Source.Path!); try { @@ -269,7 +264,7 @@ namespace Umbraco.Cms.Core.Configuration return null; } - var jsonFilePath = Path.Combine(physicalFileProvider.Root, provider.Source.Path); + var jsonFilePath = Path.Combine(physicalFileProvider.Root, provider.Source.Path!); try { diff --git a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs index 8b20a4725a..3afb9fe64a 100644 --- a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs +++ b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs @@ -32,8 +32,7 @@ public static partial class UmbracoBuilderExtensions builder.Services.AddUnique(); builder.Services.AddMultipleUnique(); builder.Services.AddUnique(); - builder.Services.AddUnique(); - builder.Services.AddUnique(factory => factory.GetRequiredService()); + builder.Services.AddSingleton(); builder.Services.AddUnique(factory => factory.GetRequiredService()); builder.Services.AddUnique(); builder.Services.AddUnique(); diff --git a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs index 68b311f8cd..a08c5f1b59 100644 --- a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs +++ b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs @@ -45,13 +45,6 @@ public abstract class RecurringHostedServiceBase : IHostedService, IDisposable _delay = delay; } - // Scheduled for removal in V11 - [Obsolete("Please use constructor that takes an ILogger instead")] - protected RecurringHostedServiceBase(TimeSpan period, TimeSpan delay) - : this(null, period, delay) - { - } - /// public void Dispose() { diff --git a/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs b/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs index bd69c7857c..d4a6265052 100644 --- a/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs +++ b/src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs @@ -40,21 +40,11 @@ public class ReportSiteTask : RecurringHostedServiceBase { } - [Obsolete("Use the constructor that takes ITelemetryService instead, scheduled for removal in V11")] - public ReportSiteTask( - ILogger logger, - IUmbracoVersion umbracoVersion, - IOptions globalSettings) - : this(logger, StaticServiceProvider.Instance.GetRequiredService()) - { - } - - /// - /// Runs the background task to send the anonymous ID - /// to telemetry service - /// - public override async Task PerformExecuteAsync(object? state) - { + /// + /// Runs the background task to send the anonymous ID + /// to telemetry service + /// + public override async Task PerformExecuteAsync(object? state){ if (_runtimeState.Level is not RuntimeLevel.Run) { // We probably haven't installed yet, so we can't get telemetry. diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs index df1457d419..3fc763d92f 100644 --- a/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs +++ b/src/Umbraco.Infrastructure/Logging/Viewer/ILogViewer.cs @@ -1,4 +1,4 @@ -using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.Logging.Viewer; @@ -39,13 +39,6 @@ public interface ILogViewer bool CheckCanOpenLogs(LogTimePeriod logTimePeriod); - /// - /// Gets the current Serilog minimum log level - /// - /// - [Obsolete("Please use GetLogLevels() instead. Scheduled for removal in V11.")] - string GetLogLevel(); - /// /// Returns the collection of logs /// diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs index 9dae731af3..56efba4ca9 100644 --- a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs +++ b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using Microsoft.Extensions.DependencyInjection; using Serilog; using Serilog.Events; @@ -14,14 +14,6 @@ public abstract class SerilogLogViewerSourceBase : ILogViewer private readonly ILogViewerConfig _logViewerConfig; private readonly ILogger _serilogLog; - [Obsolete("Please use ctor with all params instead. Scheduled for removal in V11.")] - protected SerilogLogViewerSourceBase(ILogViewerConfig logViewerConfig, ILogger serilogLog) - { - _logViewerConfig = logViewerConfig; - _logLevelLoader = StaticServiceProvider.Instance.GetRequiredService(); - _serilogLog = serilogLog; - } - protected SerilogLogViewerSourceBase(ILogViewerConfig logViewerConfig, ILogLevelLoader logLevelLoader, ILogger serilogLog) { _logViewerConfig = logViewerConfig; @@ -49,17 +41,6 @@ public abstract class SerilogLogViewerSourceBase : ILogViewer return errorCounter.Count; } - /// - /// Get the Serilog minimum-level value from the config file. - /// - [Obsolete("Please use LogLevelLoader.GetGlobalMinLogLevel() instead. Scheduled for removal in V11.")] - public string GetLogLevel() - { - LogEventLevel? logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast() - .Where(_serilogLog.IsEnabled).DefaultIfEmpty(LogEventLevel.Information).Min(); - return logLevel?.ToString() ?? string.Empty; - } - public LogLevelCounts GetLogLevelCounts(LogTimePeriod logTimePeriod) { var counter = new CountingFilter(); diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs index 3f12fd7d0d..8c1e0e2a54 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs @@ -12,7 +12,6 @@ using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Persistence.DatabaseModelDefinitions; using Umbraco.Cms.Infrastructure.Persistence.Dtos; using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax; -using Umbraco.Cms.Web.Common.DependencyInjection; using Umbraco.Extensions; using ColumnInfo = Umbraco.Cms.Infrastructure.Persistence.SqlSyntax.ColumnInfo; @@ -93,32 +92,20 @@ public class DatabaseSchemaCreator private readonly ILoggerFactory _loggerFactory; private readonly IUmbracoVersion _umbracoVersion; - [Obsolete("Please use constructor taking all parameters. Scheduled for removal in V11.")] - public DatabaseSchemaCreator( - IUmbracoDatabase? database, - ILogger logger, - ILoggerFactory loggerFactory, - IUmbracoVersion umbracoVersion, - IEventAggregator eventAggregator) - : this(database, logger, loggerFactory, umbracoVersion, eventAggregator, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } - - public DatabaseSchemaCreator( - IUmbracoDatabase? database, - ILogger logger, - ILoggerFactory loggerFactory, - IUmbracoVersion umbracoVersion, - IEventAggregator eventAggregator, - IOptionsMonitor defaultDataCreationSettings) - { - _database = database ?? throw new ArgumentNullException(nameof(database)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); - _umbracoVersion = umbracoVersion ?? throw new ArgumentNullException(nameof(umbracoVersion)); - _eventAggregator = eventAggregator; - _defaultDataCreationSettings = defaultDataCreationSettings; + public DatabaseSchemaCreator( + IUmbracoDatabase? database, + ILogger logger, + ILoggerFactory loggerFactory, + IUmbracoVersion umbracoVersion, + IEventAggregator eventAggregator, + IOptionsMonitor defaultDataCreationSettings) + { + _database = database ?? throw new ArgumentNullException(nameof(database)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); + _umbracoVersion = umbracoVersion ?? throw new ArgumentNullException(nameof(umbracoVersion)); + _eventAggregator = eventAggregator; + _defaultDataCreationSettings = defaultDataCreationSettings; if (_database?.SqlContext?.SqlSyntax == null) { diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreatorFactory.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreatorFactory.cs index 6c28f08eb6..860ed870f7 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreatorFactory.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreatorFactory.cs @@ -1,11 +1,9 @@ -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Infrastructure.Persistence; -using Umbraco.Cms.Web.Common.DependencyInjection; namespace Umbraco.Cms.Infrastructure.Migrations.Install; @@ -20,30 +18,19 @@ public class DatabaseSchemaCreatorFactory private readonly ILoggerFactory _loggerFactory; private readonly IUmbracoVersion _umbracoVersion; - [Obsolete("Please use the constructor taking all parameters. Scheduled for removal in V11.")] - public DatabaseSchemaCreatorFactory( - ILogger logger, - ILoggerFactory loggerFactory, - IUmbracoVersion umbracoVersion, - IEventAggregator eventAggregator) - : this(logger, loggerFactory, umbracoVersion, eventAggregator, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } - - public DatabaseSchemaCreatorFactory( - ILogger logger, - ILoggerFactory loggerFactory, - IUmbracoVersion umbracoVersion, - IEventAggregator eventAggregator, - IOptionsMonitor installDefaultDataSettings) - { - _logger = logger; - _loggerFactory = loggerFactory; - _umbracoVersion = umbracoVersion; - _eventAggregator = eventAggregator; - _installDefaultDataSettings = installDefaultDataSettings; - } + public DatabaseSchemaCreatorFactory( + ILogger logger, + ILoggerFactory loggerFactory, + IUmbracoVersion umbracoVersion, + IEventAggregator eventAggregator, + IOptionsMonitor installDefaultDataSettings) + { + _logger = logger; + _loggerFactory = loggerFactory; + _umbracoVersion = umbracoVersion; + _eventAggregator = eventAggregator; + _installDefaultDataSettings = installDefaultDataSettings; + } public DatabaseSchemaCreator Create(IUmbracoDatabase? database) => new DatabaseSchemaCreator(database, _logger, _loggerFactory, _umbracoVersion, _eventAggregator, _installDefaultDataSettings); diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs index 6e5e462d8d..f1369db5c3 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/AddTypedLabels.cs @@ -84,17 +84,9 @@ public class AddTypedLabels : MigrationBase .From() .Where(x => x.DataTypeId == Constants.DataTypes.LabelString)); - var intPropertyAliases = new[] - { - Constants.Conventions.Media.Width, Constants.Conventions.Media.Height, - Constants.Conventions.Member.FailedPasswordAttempts, - }; - var bigintPropertyAliases = new[] { Constants.Conventions.Media.Bytes }; - var dtPropertyAliases = new[] - { - Constants.Conventions.Member.LastLockoutDate, Constants.Conventions.Member.LastLoginDate, - Constants.Conventions.Member.LastPasswordChangeDate, - }; + var intPropertyAliases = new[] { Cms.Core.Constants.Conventions.Media.Width, Cms.Core.Constants.Conventions.Media.Height, "umbracoMemberFailedPasswordAttempts" }; + var bigintPropertyAliases = new[] { Cms.Core.Constants.Conventions.Media.Bytes }; + var dtPropertyAliases = new[] { "umbracoMemberLastLockoutDate", "umbracoMemberLastLogin", "umbracoMemberLastPasswordChangeDate" }; var intPropertyTypes = labelPropertyTypes.Where(pt => intPropertyAliases.Contains(pt.Alias)).Select(pt => pt.Id) .ToArray(); diff --git a/src/Umbraco.Infrastructure/Packaging/AutomaticPackageMigrationPlan.cs b/src/Umbraco.Infrastructure/Packaging/AutomaticPackageMigrationPlan.cs index cec42492a3..3e3c2cfae1 100644 --- a/src/Umbraco.Infrastructure/Packaging/AutomaticPackageMigrationPlan.cs +++ b/src/Umbraco.Infrastructure/Packaging/AutomaticPackageMigrationPlan.cs @@ -1,3 +1,5 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.IO; using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.PropertyEditors; @@ -42,8 +44,8 @@ public abstract class AutomaticPackageMigrationPlan : PackageMigrationPlan MediaUrlGeneratorCollection mediaUrlGenerators, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, - IMigrationContext context) - : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context) + IMigrationContext context, IOptions options) + : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context, options) { } diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index b4f49ab76b..192d1a51c3 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -906,7 +906,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging UpdateContentTypesPropertyGroups(contentType, documentType.Element("Tabs")); UpdateContentTypesProperties(contentType, documentType.Element("GenericProperties")); - if (contentType is IContentTypeWithHistoryCleanup withCleanup) + if (contentType is IContentType withCleanup) { UpdateHistoryCleanupPolicy(withCleanup, documentType.Element("HistoryCleanupPolicy")); } @@ -914,7 +914,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging return contentType; } - private void UpdateHistoryCleanupPolicy(IContentTypeWithHistoryCleanup withCleanup, XElement? element) + private void UpdateHistoryCleanupPolicy(IContentType withCleanup, XElement? element) { if (element == null) { diff --git a/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs b/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs index ae739c4361..6f0355f674 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs @@ -1,5 +1,3 @@ -using System.ComponentModel; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.IO; @@ -7,7 +5,6 @@ using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; using Umbraco.Cms.Infrastructure.Migrations; -using Umbraco.Cms.Web.Common.DependencyInjection; namespace Umbraco.Cms.Infrastructure.Packaging; @@ -41,36 +38,16 @@ public abstract class PackageMigrationBase : MigrationBase _packageMigrationsSettings = packageMigrationsSettings; } - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("Use ctor with all params")] - public PackageMigrationBase( - IPackagingService packagingService, - IMediaService mediaService, - MediaFileManager mediaFileManager, - MediaUrlGeneratorCollection mediaUrlGenerators, - IShortStringHelper shortStringHelper, - IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, - IMigrationContext context) - : this( - packagingService, - mediaService, - mediaFileManager, - mediaUrlGenerators, - shortStringHelper, - contentTypeBaseServiceProvider, - context, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } + public IImportPackageBuilder ImportPackage => BeginBuild( + new ImportPackageBuilder( + _packagingService, + _mediaService, + _mediaFileManager, + _mediaUrlGenerators, + _shortStringHelper, + _contentTypeBaseServiceProvider, + Context, + _packageMigrationsSettings)); + - public IImportPackageBuilder ImportPackage => BeginBuild( - new ImportPackageBuilder( - _packagingService, - _mediaService, - _mediaFileManager, - _mediaUrlGenerators, - _shortStringHelper, - _contentTypeBaseServiceProvider, - Context, - _packageMigrationsSettings)); } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs index fd7193e4ae..9e35999071 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs @@ -299,7 +299,7 @@ internal class ContentTypeRepository : ContentTypeRepositoryBase, { // historyCleanup property is not mandatory for api endpoint, handle the case where it's not present. // DocumentTypeSave doesn't handle this for us like ContentType constructors do. - if (entity is IContentTypeWithHistoryCleanup entityWithHistoryCleanup) + if (entity is IContentType entityWithHistoryCleanup) { var dto = new ContentVersionCleanupPolicyDto { diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs index 2207bdb16e..e49e2ffda9 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs @@ -14,26 +14,13 @@ using Umbraco.Extensions; namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement; -internal class ExternalLoginRepository : EntityRepositoryBase, IExternalLoginRepository, IExternalLoginWithKeyRepository +internal class ExternalLoginRepository : EntityRepositoryBase, IExternalLoginWithKeyRepository { public ExternalLoginRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger) : base(scopeAccessor, cache, logger) { } - - /// - [Obsolete("Use method that takes guid as param")] - public void DeleteUserLogins(int memberId) => DeleteUserLogins(memberId.ToGuid()); - - /// - [Obsolete("Use method that takes guid as param")] - public void Save(int userId, IEnumerable logins) => Save(userId.ToGuid(), logins); - - /// - [Obsolete("Use method that takes guid as param")] - public void Save(int userId, IEnumerable tokens) => Save(userId.ToGuid(), tokens); - /// /// Query for user tokens /// diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs index 323238084f..67fe818358 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs @@ -15,7 +15,7 @@ using Umbraco.Extensions; namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement; -internal class MacroRepository : EntityRepositoryBase, IMacroWithAliasRepository +internal class MacroRepository : EntityRepositoryBase, IMacroRepository { private readonly IRepositoryCachePolicy _macroByAliasCachePolicy; private readonly IShortStringHelper _shortStringHelper; diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs index 02d1383bc3..200af7ad70 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs @@ -202,13 +202,6 @@ public class MemberRepository : ContentRepositoryBase(fullSql); } - /// - [Obsolete( - "This is now a NoOp since last login date is no longer an umbraco property, set the date on the IMember directly and Save it instead, scheduled for removal in V11.")] - public void SetLastLogin(string username, DateTime date) - { - } - /// /// Gets paged member results. /// diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 76eeb33821..86eba639ce 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -169,12 +169,9 @@ public class CoreRuntime : IRuntime // Acquire the main domain - if this fails then anything that should be registered with MainDom will not operate AcquireMainDom(); - // TODO (V10): Remove this obsoleted notification publish. - await _eventAggregator.PublishAsync(new UmbracoApplicationMainDomAcquiredNotification(), cancellationToken); - // Notify for unattended install - await _eventAggregator.PublishAsync(new RuntimeUnattendedInstallNotification(), cancellationToken); - DetermineRuntimeLevel(); + await _eventAggregator.PublishAsync(new RuntimeUnattendedInstallNotification(), cancellationToken); + DetermineRuntimeLevel(); if (!State.UmbracoCanBoot()) { @@ -212,13 +209,8 @@ public class CoreRuntime : IRuntime break; } - // TODO (V10): Remove this obsoleted notification publish - await _eventAggregator.PublishAsync( - new UmbracoApplicationComponentsInstallingNotification(State.Level), - cancellationToken); - // Initialize the components - _components.Initialize(); + _components.Initialize(); await _eventAggregator.PublishAsync( new UmbracoApplicationStartingNotification(State.Level, isRestarting), diff --git a/src/Umbraco.Infrastructure/Security/BackOfficeClaimsPrincipalFactory.cs b/src/Umbraco.Infrastructure/Security/BackOfficeClaimsPrincipalFactory.cs index 9555482bbf..a6589166b2 100644 --- a/src/Umbraco.Infrastructure/Security/BackOfficeClaimsPrincipalFactory.cs +++ b/src/Umbraco.Infrastructure/Security/BackOfficeClaimsPrincipalFactory.cs @@ -46,12 +46,12 @@ public class BackOfficeClaimsPrincipalFactory : UserClaimsPrincipalFactory x.RoleId).ToArray()); diff --git a/src/Umbraco.Infrastructure/Security/BackOfficeErrorDescriber.cs b/src/Umbraco.Infrastructure/Security/BackOfficeErrorDescriber.cs index 2b9daab29f..b99eddba5d 100644 --- a/src/Umbraco.Infrastructure/Security/BackOfficeErrorDescriber.cs +++ b/src/Umbraco.Infrastructure/Security/BackOfficeErrorDescriber.cs @@ -20,7 +20,7 @@ public class BackOfficeErrorDescriber : UmbracoErrorDescriberBase Description = _textService.Localize("validation", "duplicateUserGroupName", new[] { role }), }; - public override IdentityError InvalidRoleName(string role) => new() + public override IdentityError InvalidRoleName(string? role) => new() { Code = nameof(InvalidRoleName), Description = _textService.Localize("validation", "invalidUserGroupName"), @@ -70,7 +70,7 @@ public class MembersErrorDescriber : UmbracoErrorDescriberBase Description = _textService.Localize("validation", "duplicateMemberGroupName", new[] { role }), }; - public override IdentityError InvalidRoleName(string role) => new() + public override IdentityError InvalidRoleName(string? role) => new() { Code = nameof(InvalidRoleName), Description = _textService.Localize("validation", "invalidMemberGroupName"), diff --git a/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs b/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs index 244885887e..1908a3fbfc 100644 --- a/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs +++ b/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs @@ -81,29 +81,6 @@ public class BackOfficeUserStore : UmbracoUserStore globalSettings, - IUmbracoMapper mapper, - BackOfficeErrorDescriber describer, - AppCaches appCaches) - : this( - scopeProvider, - userService, - entityService, - StaticServiceProvider.Instance.GetRequiredService(), - StaticServiceProvider.Instance.GetRequiredService>(), - mapper, - describer, - appCaches, - StaticServiceProvider.Instance.GetRequiredService()) - { - } - /// public Task ValidateSessionIdAsync(string? userId, string? sessionId) { @@ -140,12 +117,17 @@ public class BackOfficeUserStore : UmbracoUserStore(); - var emptyPasswordValue = Constants.Security.EmptyPasswordPrefix + + if (user.Email is null || user.UserName is null) + { + throw new InvalidOperationException("Email and UserName is required."); + } + + // the password must be 'something' it could be empty if authenticating + // with an external provider so we'll just generate one and prefix it, the + // prefix will help us determine if the password hasn't actually been specified yet. + // this will hash the guid with a salt so should be nicely random + var aspHasher = new PasswordHasher(); + var emptyPasswordValue = Constants.Security.EmptyPasswordPrefix + aspHasher.HashPassword(user, Guid.NewGuid().ToString("N")); var userEntity = new User(_globalSettings, user.Name, user.Email, user.UserName, emptyPasswordValue) @@ -278,16 +260,14 @@ public class BackOfficeUserStore : UmbracoUserStore - public override Task FindByNameAsync( - string userName, - CancellationToken cancellationToken = default) + public override Task FindByNameAsync(string userName, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); IUser? user = _userService.GetByUsername(userName); if (user == null) { - return Task.FromResult((BackOfficeIdentityUser)null!); + return Task.FromResult(null); } BackOfficeIdentityUser? result = AssignLoginsCallback(_mapper.Map(user)); @@ -296,7 +276,7 @@ public class BackOfficeUserStore : UmbracoUserStore - protected override Task FindUserAsync(string userId, CancellationToken cancellationToken) + protected override Task FindUserAsync(string userId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -311,7 +291,7 @@ public class BackOfficeUserStore : UmbracoUserStore - public override Task FindByEmailAsync( + public override Task FindByEmailAsync( string email, CancellationToken cancellationToken = default) { @@ -322,11 +302,11 @@ public class BackOfficeUserStore : UmbracoUserStore(user); - return Task.FromResult(AssignLoginsCallback(result))!; + return Task.FromResult(AssignLoginsCallback(result)); } /// - public override async Task SetPasswordHashAsync(BackOfficeIdentityUser user, string passwordHash, CancellationToken cancellationToken = default) + public override async Task SetPasswordHashAsync(BackOfficeIdentityUser user, string? passwordHash, CancellationToken cancellationToken = default) { await base.SetPasswordHashAsync(user, passwordHash, cancellationToken); @@ -428,7 +408,7 @@ public class BackOfficeUserStore : UmbracoUserStore /// - public override Task SetTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken) + public override Task SetTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, string? value, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -460,15 +440,15 @@ public class BackOfficeUserStore : UmbracoUserStore - protected override async Task> FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken) + protected override async Task?> FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); - BackOfficeIdentityUser user = await FindUserAsync(userId, cancellationToken); - if (user is null || user.Id is null) + BackOfficeIdentityUser? user = await FindUserAsync(userId, cancellationToken); + if (user?.Id is null) { - return null!; + return null; } IList logins = await GetLoginsAsync(user, cancellationToken); @@ -476,7 +456,7 @@ public class BackOfficeUserStore : UmbracoUserStore x.ProviderKey == providerKey && x.LoginProvider == loginProvider); if (found == null) { - return null!; + return null; } return new IdentityUserLogin @@ -489,7 +469,7 @@ public class BackOfficeUserStore : UmbracoUserStore - protected override Task> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken) + protected override Task?> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -497,11 +477,11 @@ public class BackOfficeUserStore : UmbracoUserStore)null!); + return Task.FromResult?>(null); } IIdentityUserLogin found = logins[0]; - return Task.FromResult(new IdentityUserLogin + return Task.FromResult?>(new IdentityUserLogin { LoginProvider = found.LoginProvider, ProviderKey = found.ProviderKey, @@ -511,30 +491,33 @@ public class BackOfficeUserStore : UmbracoUserStore - protected override Task> FindRoleAsync( + protected override Task?> FindRoleAsync( string normalizedRoleName, CancellationToken cancellationToken) { IUserGroup? group = _userService.GetUserGroupByAlias(normalizedRoleName); - if (group == null) + if (group?.Name is null) { - return Task.FromResult((IdentityRole)null!); + return Task.FromResult?>(null); } - return Task.FromResult(new IdentityRole(group.Name) { Id = group.Alias }); + return Task.FromResult?>(new IdentityRole(group.Name) + { + Id = group.Alias, + }); } /// - protected override async Task> FindUserRoleAsync(string userId, string roleId, CancellationToken cancellationToken) + protected override async Task?> FindUserRoleAsync(string userId, string roleId, CancellationToken cancellationToken) { - BackOfficeIdentityUser user = await FindUserAsync(userId, cancellationToken); + BackOfficeIdentityUser? user = await FindUserAsync(userId, cancellationToken); if (user == null) { return null!; } IdentityUserRole? found = user.Roles.FirstOrDefault(x => x.RoleId.InvariantEquals(roleId)); - return found!; + return found; } private BackOfficeIdentityUser? AssignLoginsCallback(BackOfficeIdentityUser? user) @@ -606,7 +589,7 @@ public class BackOfficeUserStore : UmbracoUserStore - /// Overridden to support Umbraco's own data storage requirements + /// Overridden to support Umbraco's own data storage requirements /// /// - /// The base class's implementation of this calls into FindTokenAsync, RemoveUserTokenAsync and AddUserTokenAsync, both - /// methods will only work with ORMs that are change - /// tracking ORMs like EFCore. + /// The base class's implementation of this calls into FindTokenAsync, RemoveUserTokenAsync and AddUserTokenAsync, both methods will only work with ORMs that are change + /// tracking ORMs like EFCore. /// /// public override Task RemoveTokenAsync(BackOfficeIdentityUser user, string loginProvider, string name, CancellationToken cancellationToken) diff --git a/src/Umbraco.Infrastructure/Security/ClaimsIdentityExtensions.cs b/src/Umbraco.Infrastructure/Security/ClaimsIdentityExtensions.cs index 05ab03b784..c914930e9e 100644 --- a/src/Umbraco.Infrastructure/Security/ClaimsIdentityExtensions.cs +++ b/src/Umbraco.Infrastructure/Security/ClaimsIdentityExtensions.cs @@ -38,9 +38,9 @@ public static class MergeClaimsIdentityExtensions { foreach (IdentityUserClaim claim in source.Claims .Where(claim => !_ignoredClaims.Contains(claim.ClaimType)) - .Where(claim => !destination.HasClaim(claim.ClaimType, claim.ClaimValue))) + .Where(claim => !destination.HasClaim(claim.ClaimType!, claim.ClaimValue!))) { - destination.AddClaim(new Claim(claim.ClaimType, claim.ClaimValue)); + destination.AddClaim(new Claim(claim.ClaimType!, claim.ClaimValue!)); } } } diff --git a/src/Umbraco.Infrastructure/Security/IUmbracoUserManager.cs b/src/Umbraco.Infrastructure/Security/IUmbracoUserManager.cs index fe34812334..714db070bb 100644 --- a/src/Umbraco.Infrastructure/Security/IUmbracoUserManager.cs +++ b/src/Umbraco.Infrastructure/Security/IUmbracoUserManager.cs @@ -22,14 +22,14 @@ public interface IUmbracoUserManager : IDisposable /// /// The /// A representing the result of the asynchronous operation. - Task GetUserAsync(ClaimsPrincipal principal); + Task GetUserAsync(ClaimsPrincipal principal); /// /// Get the user id from the /// /// the /// Returns the user id from the - string GetUserId(ClaimsPrincipal principal); + string? GetUserId(ClaimsPrincipal principal); /// /// Gets the external logins for the user @@ -47,7 +47,7 @@ public interface IUmbracoUserManager : IDisposable /// Finds a user by the external login provider /// /// A representing the result of the asynchronous operation. - Task FindByLoginAsync(string loginProvider, string providerKey); + Task FindByLoginAsync(string loginProvider, string providerKey); /// /// Finds and returns a user, if any, who has the specified . @@ -57,7 +57,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the user matching the specified /// if it exists. /// - Task FindByIdAsync(string? userId); + Task FindByIdAsync(string userId); /// /// Generates a password reset token for the specified , using @@ -80,7 +80,7 @@ public interface IUmbracoUserManager : IDisposable /// is to generate a token and reset it, however, when we do this we want to track a password change, not a password /// reset /// - Task ChangePasswordWithResetAsync(string userId, string token, string? newPassword); + Task ChangePasswordWithResetAsync(string userId, string token, string newPassword); /// /// Validates that an email confirmation token matches the specified . @@ -91,7 +91,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the /// of the operation. /// - Task ConfirmEmailAsync(TUser user, string? token); + Task ConfirmEmailAsync(TUser user, string token); /// /// Gets the user, if any, associated with the normalized value of the specified email address. @@ -103,7 +103,7 @@ public interface IUmbracoUserManager : IDisposable /// The task object containing the results of the asynchronous lookup operation, the user, if any, associated with a /// normalized value of the specified email address. /// - Task FindByEmailAsync(string email); + Task FindByEmailAsync(string email); /// /// Resets the 's password to the specified after @@ -116,7 +116,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the /// of the operation. /// - Task ResetPasswordAsync(TUser user, string? token, string? newPassword); + Task ResetPasswordAsync(TUser user, string token, string newPassword); /// /// Override to check the user approval value as well as the user lock out date, by default this only checks the user's @@ -216,7 +216,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the /// of the operation. /// - Task ChangePasswordAsync(TUser user, string? currentPassword, string? newPassword); + Task ChangePasswordAsync(TUser user, string currentPassword, string newPassword); /// /// Used to validate a user's session @@ -268,7 +268,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the /// of the operation. /// - Task CreateAsync(TUser user, string? password); + Task CreateAsync(TUser user, string password); /// /// Generate a password for a user based on the current password validator @@ -302,7 +302,7 @@ public interface IUmbracoUserManager : IDisposable /// The that represents the asynchronous operation, containing the user matching the specified /// if it exists. /// - Task FindByNameAsync(string userName); + Task FindByNameAsync(string userName); /// /// Increments the access failed count for the user as an asynchronous operation. @@ -373,7 +373,7 @@ public interface IUmbracoUserManager : IDisposable /// The System.Threading.Tasks.Task that represents the asynchronous operation, containing the /// Microsoft.AspNetCore.Identity.IdentityResult of the operation. /// - Task RemoveLoginAsync(TUser user, string? loginProvider, string? providerKey); + Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey); /// /// Resets the access failed count for the user @@ -395,7 +395,7 @@ public interface IUmbracoUserManager : IDisposable /// The task object containing the results of the asynchronous operation, the email address for the specified /// user. /// - Task GetEmailAsync(TUser user); + Task GetEmailAsync(TUser user); /// /// Gets the telephone number, if any, for the specified user. @@ -409,7 +409,7 @@ public interface IUmbracoUserManager : IDisposable /// A user can only support a phone number if the BackOfficeUserStore is replaced with another that implements /// IUserPhoneNumberStore /// - Task GetPhoneNumberAsync(TUser user); + Task GetPhoneNumberAsync(TUser user); /// /// Validates that a user's credentials are correct without actually logging them in. diff --git a/src/Umbraco.Infrastructure/Security/MemberRoleStore.cs b/src/Umbraco.Infrastructure/Security/MemberRoleStore.cs index eeeed4e4ec..b355bbcb18 100644 --- a/src/Umbraco.Infrastructure/Security/MemberRoleStore.cs +++ b/src/Umbraco.Infrastructure/Security/MemberRoleStore.cs @@ -131,7 +131,7 @@ public class MemberRoleStore : IQueryableRoleStore } /// - public Task GetRoleNameAsync(UmbracoIdentityRole role, CancellationToken cancellationToken = default) + public Task GetRoleNameAsync(UmbracoIdentityRole role, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -141,11 +141,11 @@ public class MemberRoleStore : IQueryableRoleStore throw new ArgumentNullException(nameof(role)); } - return Task.FromResult(role.Name)!; + return Task.FromResult(role.Name); } /// - public Task SetRoleNameAsync(UmbracoIdentityRole role, string roleName, + public Task SetRoleNameAsync(UmbracoIdentityRole role, string? roleName, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); @@ -155,23 +155,24 @@ public class MemberRoleStore : IQueryableRoleStore throw new ArgumentNullException(nameof(role)); } - role.Name = roleName; - return Task.CompletedTask; - } + + role.Name = roleName; + return Task.CompletedTask; + } /// - public Task GetNormalizedRoleNameAsync( + public Task GetNormalizedRoleNameAsync( UmbracoIdentityRole role, CancellationToken cancellationToken = default) => GetRoleNameAsync(role, cancellationToken); /// - public Task SetNormalizedRoleNameAsync(UmbracoIdentityRole role, string normalizedName, + public Task SetNormalizedRoleNameAsync(UmbracoIdentityRole role, string? normalizedName, CancellationToken cancellationToken = default) => SetRoleNameAsync(role, normalizedName, cancellationToken); /// - public Task FindByIdAsync(string roleId, CancellationToken cancellationToken = default) + public Task FindByIdAsync(string roleId, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -185,36 +186,36 @@ public class MemberRoleStore : IQueryableRoleStore // member group can be found by int or Guid, so try both if (!int.TryParse(roleId, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id)) - { - if (!Guid.TryParse(roleId, out Guid guid)) { - throw new ArgumentOutOfRangeException(nameof(roleId), $"{nameof(roleId)} is not a valid Guid"); - } + if (!Guid.TryParse(roleId, out Guid guid)) + { + throw new ArgumentOutOfRangeException(nameof(roleId), $"{nameof(roleId)} is not a valid Guid"); + } - memberGroup = _memberGroupService.GetById(guid); + memberGroup = _memberGroupService.GetById(guid); } else { memberGroup = _memberGroupService.GetById(id); } - return Task.FromResult(memberGroup == null ? null : MapFromMemberGroup(memberGroup))!; + return Task.FromResult(memberGroup == null ? null : MapFromMemberGroup(memberGroup)); } /// - public Task FindByNameAsync(string name, CancellationToken cancellationToken = default) + public Task FindByNameAsync(string name, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException(nameof(name)); - } + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentNullException(nameof(name)); + } - IMemberGroup? memberGroup = _memberGroupService.GetByName(name); - return Task.FromResult(memberGroup == null ? null : MapFromMemberGroup(memberGroup))!; - } + IMemberGroup? memberGroup = _memberGroupService.GetByName(name); + return Task.FromResult(memberGroup == null ? null : MapFromMemberGroup(memberGroup))!; + } /// /// Dispose the store diff --git a/src/Umbraco.Infrastructure/Security/MemberUserStore.cs b/src/Umbraco.Infrastructure/Security/MemberUserStore.cs index 70efeeb739..bd52d43d8b 100644 --- a/src/Umbraco.Infrastructure/Security/MemberUserStore.cs +++ b/src/Umbraco.Infrastructure/Security/MemberUserStore.cs @@ -62,7 +62,7 @@ public class MemberUserStore : UmbracoUserStore(), StaticServiceProvider.Instance.GetRequiredService()) @@ -91,7 +91,7 @@ public class MemberUserStore : UmbracoUserStore - public override Task FindByNameAsync( - string userName, - CancellationToken cancellationToken = default) + public override Task FindByNameAsync(string userName, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); IMember? user = _memberService.GetByUsername(userName); if (user == null) { - return Task.FromResult((MemberIdentityUser)null!); + return Task.FromResult(null); } - MemberIdentityUser result = AssignLoginsCallback(_mapper.Map(user))!; + MemberIdentityUser? result = AssignLoginsCallback(_mapper.Map(user))!; - return Task.FromResult(result); + return Task.FromResult(result); } public IPublishedContent? GetPublishedMember(MemberIdentityUser? user) @@ -296,7 +294,7 @@ public class MemberUserStore : UmbracoUserStore - public override Task FindByEmailAsync( + public override Task FindByEmailAsync( string email, CancellationToken cancellationToken = default) { @@ -307,11 +305,11 @@ public class MemberUserStore : UmbracoUserStore(member); - return Task.FromResult(AssignLoginsCallback(result))!; + return Task.FromResult(AssignLoginsCallback(result)); } /// - protected override Task FindUserAsync(string userId, CancellationToken cancellationToken) + protected override Task FindUserAsync(string userId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -326,7 +324,7 @@ public class MemberUserStore : UmbracoUserStore(user)))!; @@ -446,7 +444,7 @@ public class MemberUserStore : UmbracoUserStore - protected override async Task> FindUserLoginAsync(string userId, string loginProvider, + protected override async Task?> FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -462,38 +460,32 @@ public class MemberUserStore : UmbracoUserStore)null!); + return await Task.FromResult?>(null); } IList logins = await GetLoginsAsync(user, cancellationToken); UserLoginInfo? found = logins.FirstOrDefault(x => x.ProviderKey == providerKey && x.LoginProvider == loginProvider); - if (found == null) + if (found is null) { - return await Task.FromResult((IdentityUserLogin)null!); + return await Task.FromResult?>(null); } - if (user.Id is not null) + return new IdentityUserLogin { - return new IdentityUserLogin - { - LoginProvider = found.LoginProvider, - ProviderKey = found.ProviderKey, - - // TODO: We don't store this value so it will be null - ProviderDisplayName = found.ProviderDisplayName, - UserId = user.Id, - }; - } - - return null!; + LoginProvider = found.LoginProvider, + ProviderKey = found.ProviderKey, + // TODO: We don't store this value so it will be null + ProviderDisplayName = found.ProviderDisplayName, + UserId = user.Id + }; } /// - protected override Task> FindUserLoginAsync(string loginProvider, string providerKey, + protected override Task?> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -512,11 +504,11 @@ public class MemberUserStore : UmbracoUserStore)null!); + return Task.FromResult?>(null); } IIdentityUserLogin found = logins[0]; - return Task.FromResult(new IdentityUserLogin + return Task.FromResult?>(new IdentityUserLogin { LoginProvider = found.LoginProvider, ProviderKey = found.ProviderKey, @@ -533,7 +525,7 @@ public class MemberUserStore : UmbracoUserStore currentRoles = _memberService.GetAllRoles(user.UserName); + IEnumerable currentRoles = _memberService.GetAllRoles(user.UserName!); ICollection> roles = currentRoles .Select(role => new IdentityUserRole { RoleId = role, UserId = user.Id }).ToList(); @@ -544,7 +536,7 @@ public class MemberUserStore : UmbracoUserStore /// Lists all users of a given role. /// - public override Task?> GetUsersInRoleAsync( + public override Task> GetUsersInRoleAsync( string roleName, CancellationToken cancellationToken = default) { @@ -556,10 +548,10 @@ public class MemberUserStore : UmbracoUserStore? members = _memberService.GetMembersByMemberType(roleName); + IEnumerable members = _memberService.GetMembersByMemberType(roleName); - IList? membersIdentityUsers = - members?.Select(x => _mapper.Map(x)!).ToList(); + IList membersIdentityUsers = + members.Select(x => _mapper.Map(x)!).ToList(); return Task.FromResult(membersIdentityUsers); } @@ -573,8 +565,7 @@ public class MemberUserStore : UmbracoUserStore /// - public override Task SetTokenAsync(MemberIdentityUser user, string loginProvider, string name, string value, - CancellationToken cancellationToken) + public override Task SetTokenAsync(MemberIdentityUser user, string loginProvider, string name, string? value, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); @@ -632,7 +623,7 @@ public class MemberUserStore : UmbracoUserStore - protected override Task FindRoleAsync(string roleName, CancellationToken cancellationToken) + protected override Task FindRoleAsync(string roleName, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(roleName)) { @@ -640,12 +631,12 @@ public class MemberUserStore : UmbracoUserStore x.Name == roleName); - if (group == null) + if (group?.Name is null) { - return Task.FromResult((UmbracoIdentityRole)null!); + return Task.FromResult(null); } - return Task.FromResult(new UmbracoIdentityRole(group.Name) + return Task.FromResult(new UmbracoIdentityRole(group.Name) { // TODO: what should the alias be? Id = group.Id.ToString(), @@ -653,27 +644,25 @@ public class MemberUserStore : UmbracoUserStore - protected override async Task> FindUserRoleAsync(string userId, string roleId, + protected override async Task?> FindUserRoleAsync(string userId, string roleId, CancellationToken cancellationToken) { - MemberIdentityUser user = await FindUserAsync(userId, cancellationToken); - if (user == null) + MemberIdentityUser? user = await FindUserAsync(userId, cancellationToken); + if (user is null) { - return null!; + return null; } IdentityUserRole? found = user.Roles.FirstOrDefault(x => x.RoleId.InvariantEquals(roleId)); - return found!; + return found; } private MemberIdentityUser? AssignLoginsCallback(MemberIdentityUser? user) { - if (user != null) + if (user is not null) { - user.SetLoginsCallback( - new Lazy?>(() => _externalLoginService.GetExternalLogins(user.Key))); - user.SetTokensCallback(new Lazy?>(() => - _externalLoginService.GetExternalLoginTokens(user.Key))); + user.SetLoginsCallback(new Lazy?>(() => _externalLoginService.GetExternalLogins(user.Key))); + user.SetTokensCallback(new Lazy?>(() => _externalLoginService.GetExternalLoginTokens(user.Key))); } return user; @@ -736,7 +725,7 @@ public class MemberUserStore : UmbracoUserStore public class NoopLookupNormalizer : ILookupNormalizer { - public string NormalizeName(string name) => name; + public string? NormalizeName(string? name) => name; - public string NormalizeEmail(string email) => email; + public string? NormalizeEmail(string? email) => email; } diff --git a/src/Umbraco.Infrastructure/Security/UmbracoErrorDescriberBase.cs b/src/Umbraco.Infrastructure/Security/UmbracoErrorDescriberBase.cs index 671483fe7b..ade4fd1515 100644 --- a/src/Umbraco.Infrastructure/Security/UmbracoErrorDescriberBase.cs +++ b/src/Umbraco.Infrastructure/Security/UmbracoErrorDescriberBase.cs @@ -34,7 +34,7 @@ public abstract class UmbracoErrorDescriberBase : IdentityErrorDescriber Description = _textService.Localize("validation", "duplicateUsername", new[] { userName }), }; - public override IdentityError InvalidEmail(string email) => new() + public override IdentityError InvalidEmail(string? email) => new() { Code = nameof(InvalidEmail), Description = _textService.Localize("validation", "invalidEmail"), @@ -46,7 +46,7 @@ public abstract class UmbracoErrorDescriberBase : IdentityErrorDescriber Description = _textService.Localize("validation", "invalidToken"), }; - public override IdentityError InvalidUserName(string userName) => new() + public override IdentityError InvalidUserName(string? userName) => new() { Code = nameof(InvalidUserName), Description = _textService.Localize("validation", "invalidUsername"), diff --git a/src/Umbraco.Infrastructure/Security/UmbracoIdentityRole.cs b/src/Umbraco.Infrastructure/Security/UmbracoIdentityRole.cs index e38a0b89ab..af6e745f46 100644 --- a/src/Umbraco.Infrastructure/Security/UmbracoIdentityRole.cs +++ b/src/Umbraco.Infrastructure/Security/UmbracoIdentityRole.cs @@ -6,10 +6,10 @@ namespace Umbraco.Cms.Core.Security; public class UmbracoIdentityRole : IdentityRole, IRememberBeingDirty { - private string? _id; - private string? _name; + private string _id = string.Empty; + private string _name = string.Empty; - public UmbracoIdentityRole(string? roleName) + public UmbracoIdentityRole(string roleName) : base(roleName) { } @@ -26,7 +26,7 @@ public class UmbracoIdentityRole : IdentityRole, IRememberBeingDirty } /// - public override string? Id + public override string Id { get => _id; set @@ -40,11 +40,11 @@ public class UmbracoIdentityRole : IdentityRole, IRememberBeingDirty public override string? Name { get => _name; - set => BeingDirty.SetPropertyValueAndDetectChanges(value, ref _name, nameof(Name)); + set => BeingDirty.SetPropertyValueAndDetectChanges(value, ref _name!, nameof(Name)); } /// - public override string NormalizedName { get => base.Name; set => base.Name = value; } + public override string? NormalizedName { get => base.Name ?? string.Empty; set => base.Name = value; } /// /// Gets or sets a value indicating whether returns an Id has been set on this object this will be false if the object @@ -58,7 +58,7 @@ public class UmbracoIdentityRole : IdentityRole, IRememberBeingDirty // model. A good writeup of that is here: // https://stackoverflow.com/a/37362173 // For our purposes currently we won't worry about this. - public override string ConcurrencyStamp { get => base.ConcurrencyStamp; set => base.ConcurrencyStamp = value; } + public override string? ConcurrencyStamp { get => base.ConcurrencyStamp; set => base.ConcurrencyStamp = value; } /// /// Gets the for change tracking diff --git a/src/Umbraco.Infrastructure/Security/UmbracoIdentityUser.cs b/src/Umbraco.Infrastructure/Security/UmbracoIdentityUser.cs index bf79ab602d..7a44933e46 100644 --- a/src/Umbraco.Infrastructure/Security/UmbracoIdentityUser.cs +++ b/src/Umbraco.Infrastructure/Security/UmbracoIdentityUser.cs @@ -71,7 +71,7 @@ public abstract class UmbracoIdentityUser : IdentityUser, IRememberBeingDirty // model. A good writeup of that is here: // https://stackoverflow.com/a/37362173 // For our purposes currently we won't worry about this. - public override string ConcurrencyStamp { get => base.ConcurrencyStamp; set => base.ConcurrencyStamp = value; } + public override string? ConcurrencyStamp { get => base.ConcurrencyStamp; set => base.ConcurrencyStamp = value; } /// /// Gets or sets last login date @@ -85,7 +85,7 @@ public abstract class UmbracoIdentityUser : IdentityUser, IRememberBeingDirty /// /// Gets or sets email /// - public override string Email + public override string? Email { get => _email; set => BeingDirty.SetPropertyValueAndDetectChanges(value, ref _email!, nameof(Email)); @@ -247,7 +247,7 @@ public abstract class UmbracoIdentityUser : IdentityUser, IRememberBeingDirty /// /// Gets or sets user name /// - public override string UserName + public override string? UserName { get => _userName; set => BeingDirty.SetPropertyValueAndDetectChanges(value, ref _userName!, nameof(UserName)); diff --git a/src/Umbraco.Infrastructure/Security/UmbracoUserManager.cs b/src/Umbraco.Infrastructure/Security/UmbracoUserManager.cs index bc8b8078ca..dd3572c928 100644 --- a/src/Umbraco.Infrastructure/Security/UmbracoUserManager.cs +++ b/src/Umbraco.Infrastructure/Security/UmbracoUserManager.cs @@ -134,8 +134,8 @@ public abstract class UmbracoUserManager : UserManager public override async Task CheckPasswordAsync(TUser user, string? password) { - // we cannot proceed if the user passed in does not have an identity - if (user.HasIdentity == false) + // we cannot proceed if the user passed in does not have an identity, or if no password is provided. + if (user.HasIdentity == false || password is null) { return false; } @@ -158,10 +158,10 @@ public abstract class UmbracoUserManager : UserManager - public virtual async Task ChangePasswordWithResetAsync(string userId, string token, string? newPassword) + public virtual async Task ChangePasswordWithResetAsync(string userId, string token, string newPassword) { - TUser user = await FindByIdAsync(userId); - if (user == null) + TUser? user = await FindByIdAsync(userId); + if (user is null) { throw new InvalidOperationException("Could not find user"); } @@ -251,8 +251,8 @@ public abstract class UmbracoUserManager : UserManager ValidateCredentialsAsync(string username, string password) { - TUser user = await FindByNameAsync(username); - if (user == null) + TUser? user = await FindByNameAsync(username); + if (user is null) { return false; } diff --git a/src/Umbraco.Infrastructure/Security/UmbracoUserStore.cs b/src/Umbraco.Infrastructure/Security/UmbracoUserStore.cs index 7a6c9d793a..35a8f2eea9 100644 --- a/src/Umbraco.Infrastructure/Security/UmbracoUserStore.cs +++ b/src/Umbraco.Infrastructure/Security/UmbracoUserStore.cs @@ -84,7 +84,7 @@ public abstract class UmbracoUserStore } /// - public override Task FindByIdAsync(string userId, CancellationToken cancellationToken = default) => + public override Task FindByIdAsync(string userId, CancellationToken cancellationToken = default) => FindUserAsync(userId, cancellationToken); /// @@ -96,11 +96,11 @@ public abstract class UmbracoUserStore throw new NotImplementedException(); /// - public override Task GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken) + public override Task GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken) => GetEmailAsync(user, cancellationToken); /// - public override Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = default) + public override Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = default) => GetUserNameAsync(user, cancellationToken); /// @@ -221,15 +221,15 @@ public abstract class UmbracoUserStore public override Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default) => throw new NotImplementedException(); /// - public override Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken) + public override Task SetNormalizedEmailAsync(TUser user, string? normalizedEmail, CancellationToken cancellationToken) => SetEmailAsync(user, normalizedEmail, cancellationToken); /// - public override Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken = default) + public override Task SetNormalizedUserNameAsync(TUser user, string? normalizedName, CancellationToken cancellationToken = default) => SetUserNameAsync(user, normalizedName, cancellationToken); /// - public override async Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken = default) + public override async Task SetPasswordHashAsync(TUser user, string? passwordHash, CancellationToken cancellationToken = default) { await base.SetPasswordHashAsync(user, passwordHash, cancellationToken); user.LastPasswordChangeDateUtc = DateTime.UtcNow; @@ -247,7 +247,7 @@ public abstract class UmbracoUserStore /// /// [EditorBrowsable(EditorBrowsableState.Never)] - protected override Task> FindTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) => throw new NotImplementedException(); + protected override Task?> FindTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) => throw new NotImplementedException(); /// /// Not supported in Umbraco, see comments above on GetTokenAsync, RemoveTokenAsync, SetTokenAsync diff --git a/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs b/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs index 721e99bbd7..5257b2f141 100644 --- a/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs +++ b/src/Umbraco.Infrastructure/Templates/HtmlMacroParameterParser.cs @@ -79,7 +79,7 @@ public sealed class HtmlMacroParameterParser : IHtmlMacroParameterParser private IEnumerable GetUmbracoEntityReferencesFromMacros( List>> macros) { - if (_macroService is not IMacroWithAliasService macroWithAliasService) + if (_macroService is not IMacroService macroWithAliasService) { yield break; } diff --git a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj index 9676417cac..d8cd543dca 100644 --- a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj +++ b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Infrastructure Umbraco.Cms.Infrastructure Umbraco CMS Infrastructure @@ -23,6 +23,11 @@ + + + + + diff --git a/src/Umbraco.New.Cms.Core/Umbraco.New.Cms.Core.csproj b/src/Umbraco.New.Cms.Core/Umbraco.New.Cms.Core.csproj index e7c38a23af..0e0cb355cb 100644 --- a/src/Umbraco.New.Cms.Core/Umbraco.New.Cms.Core.csproj +++ b/src/Umbraco.New.Cms.Core/Umbraco.New.Cms.Core.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable Umbraco.New.Cms.Core diff --git a/src/Umbraco.New.Cms.Infrastructure/Umbraco.New.Cms.Infrastructure.csproj b/src/Umbraco.New.Cms.Infrastructure/Umbraco.New.Cms.Infrastructure.csproj index 27e27cc981..37a91d4599 100644 --- a/src/Umbraco.New.Cms.Infrastructure/Umbraco.New.Cms.Infrastructure.csproj +++ b/src/Umbraco.New.Cms.Infrastructure/Umbraco.New.Cms.Infrastructure.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable Umbraco.New.Cms.Infrastructure diff --git a/src/Umbraco.New.Cms.Web.Common/Installer/SignInUserStep.cs b/src/Umbraco.New.Cms.Web.Common/Installer/SignInUserStep.cs index 0a923da01d..accb5fd82b 100644 --- a/src/Umbraco.New.Cms.Web.Common/Installer/SignInUserStep.cs +++ b/src/Umbraco.New.Cms.Web.Common/Installer/SignInUserStep.cs @@ -22,8 +22,12 @@ public class SignInUserStep : IInstallStep public async Task ExecuteAsync(InstallData model) { - BackOfficeIdentityUser identityUser = await _backOfficeUserManager.FindByIdAsync(Constants.Security.SuperUserIdAsString); - await _backOfficeSignInManager.SignInAsync(identityUser, false); + BackOfficeIdentityUser? identityUser = await _backOfficeUserManager.FindByIdAsync(Constants.Security.SuperUserIdAsString); + + if (identityUser is not null) + { + await _backOfficeSignInManager.SignInAsync(identityUser, false); + } } public Task RequiresExecutionAsync(InstallData model) => Task.FromResult(true); diff --git a/src/Umbraco.New.Cms.Web.Common/Umbraco.New.Cms.Web.Common.csproj b/src/Umbraco.New.Cms.Web.Common/Umbraco.New.Cms.Web.Common.csproj index 159537c9d8..d9826126de 100644 --- a/src/Umbraco.New.Cms.Web.Common/Umbraco.New.Cms.Web.Common.csproj +++ b/src/Umbraco.New.Cms.Web.Common/Umbraco.New.Cms.Web.Common.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable false diff --git a/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs b/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs index 6f0360bba8..c47c04b548 100644 --- a/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs @@ -1,22 +1,18 @@ -using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.PublishedCache; using Umbraco.Cms.Infrastructure.PublishedCache.DataSource; namespace Umbraco.Cms.Infrastructure.PublishedCache; -public struct ContentNodeKit -{ - [Obsolete("This will be changed to a property in future versions")] - public ContentNode Node = null!; + public struct ContentNodeKit + { + public ContentNode Node { get; } = null!; - [Obsolete("This will be changed to a property in future versions")] - public int ContentTypeId; + public int ContentTypeId { get; } - [Obsolete("This will be changed to a property in future versions")] - public ContentData? DraftData; + public ContentData? DraftData { get; } - [Obsolete("This will be changed to a property in future versions")] - public ContentData? PublishedData; + public ContentData? PublishedData { get; } public ContentNodeKit(ContentNode node, int contentTypeId, ContentData? draftData, ContentData? publishedData) { diff --git a/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs index 7e209cb97d..a7e0b60373 100644 --- a/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs +++ b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs @@ -1,30 +1,11 @@ -namespace Umbraco.Cms.Infrastructure.PublishedCache.DataSource; +namespace Umbraco.Cms.Infrastructure.PublishedCache.DataSource; /// -/// Represents everything that is specific to an edited or published content version +/// Represents everything that is specific to an edited or published content version /// public class ContentData { - // Scheduled for removal in V11 - [Obsolete("Use ctor with all params, as the pros should be immutable")] - public ContentData() - { - Name = string.Empty; - UrlSegment = string.Empty; - Properties = null!; - CultureInfos = null!; - } - - public ContentData( - string? name, - string? urlSegment, - int versionId, - DateTime versionDate, - int writerId, - int? templateId, - bool published, - IDictionary? properties, - IReadOnlyDictionary? cultureInfos) + public ContentData(string? name, string? urlSegment, int versionId, DateTime versionDate, int writerId, int? templateId, bool published, IDictionary? properties, IReadOnlyDictionary? cultureInfos) { Name = name ?? throw new ArgumentNullException(nameof(name)); UrlSegment = urlSegment; @@ -37,69 +18,19 @@ public class ContentData CultureInfos = cultureInfos; } - public string Name - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } + public string Name { get; } + public string? UrlSegment { get; } + public int VersionId { get; } + public DateTime VersionDate { get; } + public int WriterId { get; } + public int? TemplateId { get; } + public bool Published { get; } - public string? UrlSegment - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public int VersionId - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public DateTime VersionDate - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public int WriterId - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public int? TemplateId - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public bool Published - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } - - public IDictionary Properties - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } + public IDictionary Properties { get; } /// - /// The collection of language Id to name for the content item + /// The collection of language Id to name for the content item /// - public IReadOnlyDictionary? CultureInfos - { - get; - [Obsolete("Do not change this, use ctor with params and have this object immutable.")] - set; - } + public IReadOnlyDictionary? CultureInfos { get; } } + diff --git a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj index 7b729d5097..4a2f763d36 100644 --- a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj +++ b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Infrastructure.PublishedCache Umbraco.Cms.PublishedCache.NuCache Umbraco CMS Published Cache diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs index 390482276e..7704344d4e 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs @@ -186,11 +186,13 @@ public class AuthenticationController : UmbracoApiControllerBase [ValidateAngularAntiForgeryToken] public async Task PostUnLinkLogin(UnLinkLoginModel unlinkLoginModel) { - BackOfficeIdentityUser? user = await _userManager.FindByIdAsync(User.Identity?.GetUserId()); - if (user == null) + var userId = User.Identity?.GetUserId(); + if (userId is null) { - throw new InvalidOperationException("Could not find user"); + throw new InvalidOperationException("Could not find userId"); } + var user = await _userManager.FindByIdAsync(userId); + if (user == null) throw new InvalidOperationException("Could not find user"); AuthenticationScheme? authType = (await _signInManager.GetExternalAuthenticationSchemesAsync()) .FirstOrDefault(x => x.Name == unlinkLoginModel.LoginProvider); @@ -484,16 +486,19 @@ public class AuthenticationController : UmbracoApiControllerBase UmbracoUserExtensions.GetUserCulture(user.Culture, _textService, _globalSettings), new[] { code }); - if (provider == "Email") - { - var mailMessage = new EmailMessage(from, user.Email, subject, message, true); - - await _emailSender.SendAsync(mailMessage, Constants.Web.EmailTypes.TwoFactorAuth); - } - else if (provider == "Phone") - { - await _smsSender.SendSmsAsync(await _userManager.GetPhoneNumberAsync(user), message); - } + if (provider == "Email") + { + var mailMessage = new EmailMessage(from, user.Email, subject, message, true); + await _emailSender.SendAsync(mailMessage, Constants.Web.EmailTypes.TwoFactorAuth); + } + else if (provider == "Phone") + { + var phoneNumber = await _userManager.GetPhoneNumberAsync(user); + if (phoneNumber is not null) + { + await _smsSender.SendSmsAsync(phoneNumber, message); + } + } return Ok(); } @@ -544,6 +549,10 @@ public class AuthenticationController : UmbracoApiControllerBase { BackOfficeIdentityUser? identityUser = await _userManager.FindByIdAsync(model.UserId.ToString(CultureInfo.InvariantCulture)); + if (identityUser is null) + { + return new ValidationErrorResult("Could not find user"); + } IdentityResult result = await _userManager.ResetPasswordAsync(identityUser, model.ResetCode, model.Password); if (result.Succeeded) diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs index c5567d1796..ae0b9c961f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs @@ -386,7 +386,7 @@ public class BackOfficeController : UmbracoController [HttpGet] public async Task ExternalLinkLoginCallback() { - BackOfficeIdentityUser user = await _userManager.GetUserAsync(User); + BackOfficeIdentityUser? user = await _userManager.GetUserAsync(User); if (user == null) { // ... this should really not happen @@ -504,9 +504,8 @@ public class BackOfficeController : UmbracoController } else if (result == SignInResult.TwoFactorRequired) { - BackOfficeIdentityUser? attemptedUser = - await _userManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey); - if (attemptedUser == null) + BackOfficeIdentityUser? attemptedUser = await _userManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey); + if (attemptedUser?.UserName is null) { return new ValidationErrorResult( $"No local user found for the login provider {loginInfo.LoginProvider} - {loginInfo.ProviderKey}"); diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs index 6471b5b2ae..c8a3c710ec 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs @@ -376,7 +376,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers }, { "currentUserApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl( - controller => controller.PostChangePassword(new ChangingPasswordModel())) + controller => controller.PostSetAvatar(new List())) }, { "entityApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl( @@ -416,7 +416,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers }, { "memberTypeApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl( - controller => controller.GetAllTypes()) + controller => controller.GetById(0)) }, { "memberTypeQueryApiBaseUrl", _linkGenerator.GetUmbracoApiServiceBaseUrl( diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index f867ccc5a1..87f881ff69 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -81,47 +81,15 @@ public class CurrentUserController : UmbracoAuthorizedJsonController _userDataService = userDataService; } - [Obsolete("This constructor is obsolete and will be removed in v11, use constructor with all values")] - public CurrentUserController( - MediaFileManager mediaFileManager, - IOptions contentSettings, - IHostingEnvironment hostingEnvironment, - IImageUrlGenerator imageUrlGenerator, - IBackOfficeSecurityAccessor backofficeSecurityAccessor, - IUserService userService, - IUmbracoMapper umbracoMapper, - IBackOfficeUserManager backOfficeUserManager, - ILoggerFactory loggerFactory, - ILocalizedTextService localizedTextService, - AppCaches appCaches, - IShortStringHelper shortStringHelper, - IPasswordChanger passwordChanger) : this( - mediaFileManager, - StaticServiceProvider.Instance.GetRequiredService>(), - hostingEnvironment, - imageUrlGenerator, - backofficeSecurityAccessor, - userService, - umbracoMapper, - backOfficeUserManager, - localizedTextService, - appCaches, - shortStringHelper, - passwordChanger, - StaticServiceProvider.Instance.GetRequiredService()) - { - } - - - /// - /// Returns permissions for all nodes passed in for the current user - /// - /// - /// - [HttpPost] - public Dictionary GetPermissions(int[] nodeIds) - { - EntityPermissionCollection permissions = _userService + /// + /// Returns permissions for all nodes passed in for the current user + /// + /// + /// + [HttpPost] + public Dictionary GetPermissions(int[] nodeIds) + { + EntityPermissionCollection permissions = _userService .GetPermissions(_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser, nodeIds); var permissionsDictionary = new Dictionary(); @@ -230,12 +198,13 @@ public class CurrentUserController : UmbracoAuthorizedJsonController [AllowAnonymous] public async Task> PostSetInvitedUserPassword([FromBody] string newPassword) { - BackOfficeIdentityUser? user = await _backOfficeUserManager.FindByIdAsync(_backofficeSecurityAccessor - .BackOfficeSecurity?.GetUserId().ResultOr(0).ToString()); - if (user == null) + var userId = _backofficeSecurityAccessor.BackOfficeSecurity?.GetUserId().ResultOr(0).ToString(); + if (userId is null) { - throw new InvalidOperationException("Could not find user"); + throw new InvalidOperationException("Could not find user Id"); } + var user = await _backOfficeUserManager.FindByIdAsync(userId); + if (user == null) throw new InvalidOperationException("Could not find user"); IdentityResult result = await _backOfficeUserManager.AddPasswordAsync(user, newPassword); @@ -335,8 +304,18 @@ public class CurrentUserController : UmbracoAuthorizedJsonController [ValidateAngularAntiForgeryToken] public async Task> GetCurrentUserLinkedLogins() { - BackOfficeIdentityUser identityUser = await _backOfficeUserManager.FindByIdAsync(_backofficeSecurityAccessor - .BackOfficeSecurity?.GetUserId().ResultOr(0).ToString(CultureInfo.InvariantCulture)); + var userId = _backofficeSecurityAccessor.BackOfficeSecurity?.GetUserId().ResultOr(0).ToString(CultureInfo.InvariantCulture); + if (userId is null) + { + throw new InvalidOperationException("Could not find user Id"); + } + + BackOfficeIdentityUser? identityUser = await _backOfficeUserManager.FindByIdAsync(userId); + + if (identityUser is null) + { + throw new InvalidOperationException("Could not find user"); + } // deduplicate in case there are duplicates (there shouldn't be now since we have a unique constraint on the external logins // but there didn't used to be) diff --git a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs index 92779c18fa..ba9809f657 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/EntityController.cs @@ -471,46 +471,6 @@ public class EntityController : UmbracoAuthorizedJsonController .Select(id => new { Id = id, Url = MediaOrDocumentUrl(id) }).ToDictionary(x => x.Id, x => x.Url); } - /// - /// Get entity URLs by UDIs - /// - /// - /// A list of UDIs to lookup items by - /// - /// The culture to fetch the URL for - /// Dictionary mapping Udi -> Url - /// - /// We allow for POST because there could be quite a lot of Ids. - /// - [HttpGet] - [HttpPost] - [Obsolete("Use GetUrlsByIds instead.")] - public IDictionary GetUrlsByUdis([FromJsonPath] Udi[] udis, string? culture = null) - { - if (udis == null || !udis.Any()) - { - return new Dictionary(); - } - - var udiEntityType = udis.First().EntityType; - UmbracoEntityTypes entityType; - - switch (udiEntityType) - { - case Constants.UdiEntityType.Document: - entityType = UmbracoEntityTypes.Document; - break; - case Constants.UdiEntityType.Media: - entityType = UmbracoEntityTypes.Media; - break; - default: - entityType = (UmbracoEntityTypes)(-1); - break; - } - - return GetUrlsByIds(udis, entityType, culture); - } - /// /// Gets the URL of an entity /// diff --git a/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs b/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs index 6cb7f1f4bc..8dd599be46 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/HelpController.cs @@ -18,12 +18,6 @@ public class HelpController : UmbracoAuthorizedJsonController private readonly ILogger _logger; private HelpPageSettings? _helpPageSettings; - [Obsolete("Use constructor that takes IOptions")] - public HelpController(ILogger logger) - : this(logger, StaticServiceProvider.Instance.GetRequiredService>()) - { - } - [ActivatorUtilitiesConstructor] public HelpController( ILogger logger, diff --git a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs index bb515b61fc..4cb7dc52fc 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LanguageController.cs @@ -30,21 +30,13 @@ public class LanguageController : UmbracoAuthorizedJsonController _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); } - [Obsolete("Use the constructor without global settings instead, scheduled for removal in V11.")] - public LanguageController(ILocalizationService localizationService, IUmbracoMapper umbracoMapper, - IOptionsSnapshot globalSettings) - : this(localizationService, umbracoMapper) - { - } - - /// - /// Returns all cultures available for creating languages. - /// - /// - [HttpGet] - public IDictionary GetAllCultures() - => CultureInfo.GetCultures(CultureTypes.AllCultures).DistinctBy(x => x.Name).OrderBy(x => x.EnglishName) - .ToDictionary(x => x.Name, x => x.EnglishName); + /// + /// Returns all cultures available for creating languages. + /// + /// + [HttpGet] + public IDictionary GetAllCultures() + => CultureInfo.GetCultures(CultureTypes.AllCultures).DistinctBy(x => x.Name).OrderBy(x => x.EnglishName).ToDictionary(x => x.Name, x => x.EnglishName); /// /// Returns all currently configured languages. diff --git a/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs b/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs index 4c3cce59a5..7389af5112 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/LogViewerController.cs @@ -22,12 +22,6 @@ public class LogViewerController : BackOfficeNotificationsController private readonly ILogLevelLoader _logLevelLoader; private readonly ILogViewer _logViewer; - [Obsolete] - public LogViewerController(ILogViewer logViewer) - : this(logViewer, StaticServiceProvider.Instance.GetRequiredService()) - { - } - [ActivatorUtilitiesConstructor] public LogViewerController(ILogViewer logViewer, ILogLevelLoader logLevelLoader) { @@ -147,8 +141,4 @@ public class LogViewerController : BackOfficeNotificationsController [HttpGet] public ReadOnlyDictionary GetLogLevels() => _logLevelLoader.GetLogLevelsFromSinks(); - - [Obsolete("Please use GetLogLevels() instead. Scheduled for removal in V11.")] - [HttpGet] - public string GetLogLevel() => _logViewer.GetLogLevel(); } diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs index 50c54f420f..b81d120295 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs @@ -986,37 +986,6 @@ public class MediaController : ContentControllerBase return new ActionResult(toMove); } - [Obsolete( - "Please use TrackedReferencesController.GetPagedRelationsForItem() instead. Scheduled for removal in V11.")] - public PagedResult GetPagedReferences(int id, string entityType, int pageNumber = 1, - int pageSize = 100) - { - if (pageNumber <= 0 || pageSize <= 0) - { - throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero"); - } - - UmbracoObjectTypes objectType = ObjectTypes.GetUmbracoObjectType(entityType); - var udiType = objectType.GetUdiType(); - - IEnumerable relations = - _relationService.GetPagedParentEntitiesByChildId(id, pageNumber - 1, pageSize, out var totalRecords, - objectType); - - return new PagedResult(totalRecords, pageNumber, pageSize) - { - Items = relations.Cast().Select(rel => new EntityBasic - { - Id = rel.Id, - Key = rel.Key, - Udi = Udi.Create(udiType, rel.Key), - Icon = rel.ContentTypeIcon, - Name = rel.Name, - Alias = rel.ContentTypeAlias - }) - }; - } - #region GetChildren private int[]? _userStartNodes; diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs index 70f337f44f..b7220a3941 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs @@ -367,7 +367,7 @@ public class MemberController : ContentControllerBase contentItem.IsApproved, contentItem.Name); - IdentityResult created = await _memberManager.CreateAsync(identityMember, contentItem.Password?.NewPassword); + IdentityResult created = await _memberManager.CreateAsync(identityMember, contentItem.Password?.NewPassword!); if (created.Succeeded == false) { @@ -513,8 +513,12 @@ public class MemberController : ContentControllerBase } var needsResync = false; - - MemberIdentityUser identityMember = await _memberManager.FindByIdAsync(contentItem.Id?.ToString()); + var memberId = contentItem.Id?.ToString(); + if (memberId is null) + { + return ValidationProblem("Member was not found"); + } + MemberIdentityUser? identityMember = await _memberManager.FindByIdAsync(memberId); if (identityMember == null) { return ValidationProblem("Member was not found"); diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs index 984cff0582..4184cc5798 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberTypeController.cs @@ -183,17 +183,6 @@ public class MemberTypeController : ContentTypeControllerBase return dto; } - - /// - /// Returns all member types - /// - [Obsolete( - "Use MemberTypeQueryController.GetAllTypes instead as it only requires AuthorizationPolicies.TreeAccessMembersOrMemberTypes and not both this and AuthorizationPolicies.TreeAccessMemberTypes")] - [Authorize(Policy = AuthorizationPolicies.TreeAccessMembersOrMemberTypes)] - public IEnumerable GetAllTypes() => - _memberTypeService.GetAll() - .Select(_umbracoMapper.Map).WhereNotNull(); - public ActionResult PostSave(MemberTypeSave contentTypeSave) { //get the persisted member type diff --git a/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs b/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs index be57a93328..6a4e7ca236 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/TemplateController.cs @@ -39,23 +39,14 @@ public class TemplateController : BackOfficeNotificationsController throw new ArgumentNullException(nameof(defaultViewContentProvider)); } - [Obsolete("Use ctor will all params")] - public TemplateController( - IFileService fileService, - IUmbracoMapper umbracoMapper, - IShortStringHelper shortStringHelper) - : this(fileService, umbracoMapper, shortStringHelper, StaticServiceProvider.Instance.GetRequiredService()) - { - } - - /// - /// Gets data type by alias - /// - /// - /// - public TemplateDisplay? GetByAlias(string alias) - { - ITemplate? template = _fileService.GetTemplate(alias); + /// + /// Gets data type by alias + /// + /// + /// + public TemplateDisplay? GetByAlias(string alias) + { + ITemplate? template = _fileService.GetTemplate(alias); return template == null ? null : _umbracoMapper.Map(template); } diff --git a/src/Umbraco.Web.BackOffice/Controllers/TwoFactorLoginController.cs b/src/Umbraco.Web.BackOffice/Controllers/TwoFactorLoginController.cs index b0e081e9de..68a8773362 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/TwoFactorLoginController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/TwoFactorLoginController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -23,7 +23,7 @@ public class TwoFactorLoginController : UmbracoAuthorizedJsonController private readonly IBackOfficeSignInManager _backOfficeSignInManager; private readonly IBackOfficeUserManager _backOfficeUserManager; private readonly ILogger _logger; - private readonly ITwoFactorLoginService2 _twoFactorLoginService; + private readonly ITwoFactorLoginService _twoFactorLoginService; private readonly IOptionsSnapshot _twoFactorLoginViewOptions; public TwoFactorLoginController( @@ -36,15 +36,7 @@ public class TwoFactorLoginController : UmbracoAuthorizedJsonController { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _logger = logger; - - if (twoFactorLoginService is not ITwoFactorLoginService2 twoFactorLoginService2) - { - throw new ArgumentException( - "twoFactorLoginService needs to implement ITwoFactorLoginService2 until the interfaces are merged", - nameof(twoFactorLoginService)); - } - - _twoFactorLoginService = twoFactorLoginService2; + _twoFactorLoginService = twoFactorLoginService; _backOfficeSignInManager = backOfficeSignInManager; _backOfficeUserManager = backOfficeUserManager; _twoFactorLoginViewOptions = twoFactorLoginViewOptions; @@ -73,7 +65,11 @@ public class TwoFactorLoginController : UmbracoAuthorizedJsonController [HttpGet] public async Task>> Get2FAProvidersForUser(int userId) { - BackOfficeIdentityUser user = await _backOfficeUserManager.FindByIdAsync(userId.ToString(CultureInfo.InvariantCulture)); + BackOfficeIdentityUser? user = await _backOfficeUserManager.FindByIdAsync(userId.ToString(CultureInfo.InvariantCulture)); + if (user is null) + { + throw new InvalidOperationException("Could not find user"); + } var enabledProviderNameHashSet = new HashSet(await _twoFactorLoginService.GetEnabledTwoFactorProviderNamesAsync(user.Key)); diff --git a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs index f734d8626b..916ff3d495 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs @@ -565,10 +565,20 @@ public class UsersController : BackOfficeNotificationsController return new ActionResult(user); } - private async Task SendUserInviteEmailAsync(UserBasic? userDisplay, string? from, string? fromEmail, IUser? to, - string? message) + private async Task SendUserInviteEmailAsync(UserBasic? userDisplay, string? from, string? fromEmail, IUser? to, string? message) { - BackOfficeIdentityUser user = await _userManager.FindByIdAsync(((int?)userDisplay?.Id).ToString()); + var userId = userDisplay?.Id?.ToString(); + if (userId is null) + { + throw new InvalidOperationException("Could not find user Id"); + } + var user = await _userManager.FindByIdAsync(userId); + + if (user is null) + { + throw new InvalidOperationException("Could not find user"); + } + var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); // Use info from SMTP Settings if configured, otherwise set fromEmail as fallback diff --git a/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilder.LocalizedText.cs b/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilder.LocalizedText.cs index 54e25240e0..9d677bce66 100644 --- a/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilder.LocalizedText.cs +++ b/src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilder.LocalizedText.cs @@ -48,7 +48,7 @@ namespace Umbraco.Extensions IEnumerable userLangFileSources = contentFileProvider.GetDirectoryContents(userConfigLangFolder) .Where(x => x.IsDirectory && x.Name.InvariantEquals("lang")) - .Select(x => new DirectoryInfo(x.PhysicalPath)) + .Select(x => new DirectoryInfo(x.PhysicalPath!)) .SelectMany(x => x.GetFiles("*.user.xml", SearchOption.TopDirectoryOnly)) .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true)); @@ -87,7 +87,7 @@ namespace Umbraco.Extensions .GetDirectoryContents(langFolder) .Where(x => !string.IsNullOrEmpty(x.PhysicalPath)) .Where(x => x.Name.InvariantEndsWith(".xml")) - .Select(x => new FileInfo(x.PhysicalPath)); + .Select(x => new FileInfo(x.PhysicalPath!)); foreach (FileInfo file in localizationFiles) { diff --git a/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs b/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs index 13896c8912..1ac7f20819 100644 --- a/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs +++ b/src/Umbraco.Web.BackOffice/Install/CreateUnattendedUserNotificationHandler.cs @@ -75,7 +75,7 @@ public class CreateUnattendedUserNotificationHandler : INotificationAsyncHandler using IServiceScope scope = _serviceScopeFactory.CreateScope(); IBackOfficeUserManager backOfficeUserManager = scope.ServiceProvider.GetRequiredService(); - BackOfficeIdentityUser membershipUser = + BackOfficeIdentityUser? membershipUser = await backOfficeUserManager.FindByIdAsync(Constants.Security.SuperUserIdAsString); if (membershipUser == null) { diff --git a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index 555c14ff96..52068c6f8d 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -94,8 +94,12 @@ public class InstallApiController : ControllerBase if (levelBeforeRestart == RuntimeLevel.Install) { - BackOfficeIdentityUser identityUser = await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); - _backOfficeSignInManager.SignInAsync(identityUser, false); + BackOfficeIdentityUser? identityUser = + await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); + if (identityUser is not null) + { + _backOfficeSignInManager.SignInAsync(identityUser, false); + } } return NoContent(); diff --git a/src/Umbraco.Web.BackOffice/Middleware/ConfigureGlobalOptionsForKeepAliveMiddlware.cs b/src/Umbraco.Web.BackOffice/Middleware/ConfigureGlobalOptionsForKeepAliveMiddlware.cs index 15366ec113..5156ad3af5 100644 --- a/src/Umbraco.Web.BackOffice/Middleware/ConfigureGlobalOptionsForKeepAliveMiddlware.cs +++ b/src/Umbraco.Web.BackOffice/Middleware/ConfigureGlobalOptionsForKeepAliveMiddlware.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration.Models; namespace Umbraco.Cms.Web.BackOffice.Middleware; @@ -18,6 +18,6 @@ public sealed class ConfigureGlobalOptionsForKeepAliveMiddlware : IPostConfigure /// /// /// - public void PostConfigure(string name, GlobalSettings options) => + public void PostConfigure(string? name, GlobalSettings options) => options.ReservedUrls += _keepAliveSettings.Value.KeepAlivePingUrl; } diff --git a/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs b/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs index 24217d331b..f4aed22fbe 100644 --- a/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs +++ b/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs @@ -62,10 +62,10 @@ public class BackOfficeAuthenticationBuilder : AuthenticationBuilder internal class EnsureBackOfficeScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { - public void PostConfigure(string name, TOptions options) + public void PostConfigure(string? name, TOptions options) { // ensure logic only applies to backoffice authentication schemes - if (name.StartsWith(Constants.Security.BackOfficeExternalAuthenticationTypePrefix)) + if (name is not null && name.StartsWith(Constants.Security.BackOfficeExternalAuthenticationTypePrefix)) { options.SignInScheme = Constants.Security.BackOfficeExternalAuthenticationType; } diff --git a/src/Umbraco.Web.BackOffice/Security/BackOfficeSessionIdValidator.cs b/src/Umbraco.Web.BackOffice/Security/BackOfficeSessionIdValidator.cs index 15413db2a7..f0cb1beee5 100644 --- a/src/Umbraco.Web.BackOffice/Security/BackOfficeSessionIdValidator.cs +++ b/src/Umbraco.Web.BackOffice/Security/BackOfficeSessionIdValidator.cs @@ -126,7 +126,12 @@ public class BackOfficeSessionIdValidator } var userId = currentIdentity.GetUserId(); - BackOfficeIdentityUser? user = await _userManager.FindByIdAsync(userId); + if (userId is null) + { + return false; + } + + var user = await _userManager.FindByIdAsync(userId); if (user == null) { return false; diff --git a/src/Umbraco.Web.BackOffice/Security/BackOfficeSignInManager.cs b/src/Umbraco.Web.BackOffice/Security/BackOfficeSignInManager.cs index 74f5fb5eb8..19a231cf52 100644 --- a/src/Umbraco.Web.BackOffice/Security/BackOfficeSignInManager.cs +++ b/src/Umbraco.Web.BackOffice/Security/BackOfficeSignInManager.cs @@ -117,7 +117,7 @@ public class BackOfficeSignInManager : UmbracoSignInManagerThe external login URL users should be redirected to during the login flow. /// The current user's identifier, which will be used to provide CSRF protection. /// A configured . - public override AuthenticationProperties ConfigureExternalAuthenticationProperties(string provider, string? redirectUrl, string? userId = null) + public override AuthenticationProperties ConfigureExternalAuthenticationProperties(string? provider, string? redirectUrl, string? userId = null) { // borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs // to be able to use our own XsrfKey/LoginProviderKey because the default is private :/ @@ -197,7 +197,7 @@ public class BackOfficeSignInManager : UmbracoSignInManager - public void Configure(string name, CookieAuthenticationOptions options) + public void Configure(string? name, CookieAuthenticationOptions options) { if (name != Constants.Security.BackOfficeAuthenticationType) { diff --git a/src/Umbraco.Web.BackOffice/Security/PasswordChanger.cs b/src/Umbraco.Web.BackOffice/Security/PasswordChanger.cs index 59ea9a7b81..25f0548386 100644 --- a/src/Umbraco.Web.BackOffice/Security/PasswordChanger.cs +++ b/src/Umbraco.Web.BackOffice/Security/PasswordChanger.cs @@ -52,7 +52,7 @@ internal class PasswordChanger : IPasswordChanger where TUser : Um } var userId = changingPasswordModel.Id.ToString(); - TUser identityUser = await userMgr.FindByIdAsync(userId); + TUser? identityUser = await userMgr.FindByIdAsync(userId); if (identityUser == null) { // this really shouldn't ever happen... but just in case @@ -96,7 +96,7 @@ internal class PasswordChanger : IPasswordChanger where TUser : Um } // can we change to the new password? - IdentityResult changeResult = await userMgr.ChangePasswordAsync(identityUser, changingPasswordModel.OldPassword, changingPasswordModel.NewPassword); + IdentityResult changeResult = await userMgr.ChangePasswordAsync(identityUser, changingPasswordModel.OldPassword!, changingPasswordModel.NewPassword); if (changeResult.Succeeded == false) { // no, fail with error messages for "password" diff --git a/src/Umbraco.Web.BackOffice/Services/IconService.cs b/src/Umbraco.Web.BackOffice/Services/IconService.cs index 7f060dc756..fa6bf3eb4c 100644 --- a/src/Umbraco.Web.BackOffice/Services/IconService.cs +++ b/src/Umbraco.Web.BackOffice/Services/IconService.cs @@ -141,7 +141,7 @@ public class IconService : IIconService IEnumerable coreIcons = iconFolder .Where(x => !x.IsDirectory && x.Name.EndsWith(".svg")) - .Select(x => new FileInfo(x.PhysicalPath)); + .Select(x => new FileInfo(x.PhysicalPath!)); icons.UnionWith(coreIcons); diff --git a/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs b/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs index f9efabd83f..8b8a885fd5 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs @@ -33,21 +33,6 @@ public abstract class MemberTypeAndGroupTreeControllerBase : TreeController _memberTypeService = memberTypeService; } - [Obsolete("Use ctor injecting IMemberTypeService")] - protected MemberTypeAndGroupTreeControllerBase( - ILocalizedTextService localizedTextService, - UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, - IMenuItemCollectionFactory menuItemCollectionFactory, - IEventAggregator eventAggregator) - : this( - localizedTextService, - umbracoApiControllerTypeCollection, - menuItemCollectionFactory, - eventAggregator, - StaticServiceProvider.Instance.GetRequiredService()) - { - } - public IMenuItemCollectionFactory MenuItemCollectionFactory { get; } protected override ActionResult GetTreeNodes(string id, FormCollection queryStrings) diff --git a/src/Umbraco.Web.BackOffice/Umbraco.Web.BackOffice.csproj b/src/Umbraco.Web.BackOffice/Umbraco.Web.BackOffice.csproj index 21066d19bb..7e4a3eb700 100644 --- a/src/Umbraco.Web.BackOffice/Umbraco.Web.BackOffice.csproj +++ b/src/Umbraco.Web.BackOffice/Umbraco.Web.BackOffice.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Library Umbraco.Cms.Web.BackOffice Umbraco.Cms.Web.BackOffice diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs index 57f1e288b7..af8fec7f69 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs @@ -82,7 +82,7 @@ public class AspNetCoreHostingEnvironment : IHostingEnvironment public Uri ApplicationMainUrl { get; private set; } = null!; /// - public string SiteName { get; private set; } = null!; + public string? SiteName { get; private set; } /// public string ApplicationId diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs index 38d67ff2f0..abb2b71a4e 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs @@ -44,10 +44,10 @@ public class AspNetCoreRequestAccessor : IRequestAccessor, INotificationHandler< }); /// - public string GetRequestValue(string name) => GetFormValue(name) ?? GetQueryStringValue(name); + public string? GetRequestValue(string name) => GetFormValue(name) ?? GetQueryStringValue(name); /// - public string GetQueryStringValue(string name) => _httpContextAccessor.GetRequiredHttpContext().Request.Query[name]; + public string? GetQueryStringValue(string name) => _httpContextAccessor.GetRequiredHttpContext().Request.Query[name]; /// public Uri? GetRequestUrl() => _httpContextAccessor.HttpContext != null diff --git a/src/Umbraco.Web.Common/AspNetCore/OptionsMonitorAdapter.cs b/src/Umbraco.Web.Common/AspNetCore/OptionsMonitorAdapter.cs index 112841a722..fd3d3516af 100644 --- a/src/Umbraco.Web.Common/AspNetCore/OptionsMonitorAdapter.cs +++ b/src/Umbraco.Web.Common/AspNetCore/OptionsMonitorAdapter.cs @@ -15,7 +15,7 @@ internal class OptionsMonitorAdapter : IOptionsMonitor public T CurrentValue { get; } - public T Get(string name) => CurrentValue; + public T Get(string? name) => CurrentValue; public IDisposable OnChange(Action listener) => throw new NotImplementedException(); } diff --git a/src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs index c91d0fb6c2..e8961dba0a 100644 --- a/src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/FormCollectionExtensions.cs @@ -49,7 +49,7 @@ public static class FormCollectionExtensions /// /// /// - public static string GetRequiredString(this FormCollection items, string key) + public static string? GetRequiredString(this FormCollection items, string key) { if (items.HasKey(key) == false) { diff --git a/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs b/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs index bdacae95ef..e4481f7f28 100644 --- a/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs @@ -347,12 +347,4 @@ public static class FriendlyImageCropperTemplateExtensions useCropDimensions, cacheBusterValue, furtherOptions); - - [Obsolete( - "Use GetCropUrl to merge local and media crops, get automatic cache buster value and have more parameters.")] - public static string GetLocalCropUrl( - this MediaWithCrops mediaWithCrops, - string alias, - string? cacheBusterValue = null) => mediaWithCrops.LocalCrops.Src + - mediaWithCrops.LocalCrops.GetCropUrl(alias, ImageUrlGenerator, cacheBusterValue: cacheBusterValue); } diff --git a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs index 226755039e..0f2da0ac4e 100644 --- a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs @@ -65,7 +65,7 @@ public static class HttpContextExtensions /// /// Get the value in the request form or query string for the key /// - public static string GetRequestValue(this HttpContext context, string key) + public static string? GetRequestValue(this HttpContext context, string key) { HttpRequest request = context.Request; if (!request.HasFormContentType) @@ -73,7 +73,7 @@ public static class HttpContextExtensions return request.Query[key]; } - string value = request.Form[key]; + string? value = request.Form[key]; return value ?? request.Query[key]; } diff --git a/src/Umbraco.Web.Common/Extensions/TypeExtensions.cs b/src/Umbraco.Web.Common/Extensions/TypeExtensions.cs new file mode 100644 index 0000000000..60edea5b15 --- /dev/null +++ b/src/Umbraco.Web.Common/Extensions/TypeExtensions.cs @@ -0,0 +1,10 @@ +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.PublishedContent; + +namespace Umbraco.Extensions; + +internal static class TypeExtensions +{ + public static bool IsRenderingModel(this Type type) + => typeof(ContentModel).IsAssignableFrom(type) || typeof(IPublishedContent).IsAssignableFrom(type); +} diff --git a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs index cf73ba481c..74339bac43 100644 --- a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs +++ b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs @@ -52,41 +52,6 @@ public class UmbracoRequestMiddleware : IMiddleware private readonly IVariationContextAccessor _variationContextAccessor; private SmidgeOptions _smidgeOptions; - /// - /// Initializes a new instance of the class. - /// - // Obsolete, scheduled for removal in V11 - [Obsolete("Use constructor that takes an IOptions")] - public UmbracoRequestMiddleware( - ILogger logger, - IUmbracoContextFactory umbracoContextFactory, - IRequestCache requestCache, - IEventAggregator eventAggregator, - IProfiler profiler, - IHostingEnvironment hostingEnvironment, - UmbracoRequestPaths umbracoRequestPaths, - BackOfficeWebAssets backOfficeWebAssets, - IOptionsMonitor smidgeOptions, - IRuntimeState runtimeState, - IVariationContextAccessor variationContextAccessor, - IDefaultCultureAccessor defaultCultureAccessor) - : this( - logger, - umbracoContextFactory, - requestCache, - eventAggregator, - profiler, - hostingEnvironment, - umbracoRequestPaths, - backOfficeWebAssets, - smidgeOptions, - runtimeState, - variationContextAccessor, - defaultCultureAccessor, - StaticServiceProvider.Instance.GetRequiredService>()) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/src/Umbraco.Web.Common/Mvc/UmbracoMvcConfigureOptions.cs b/src/Umbraco.Web.Common/Mvc/UmbracoMvcConfigureOptions.cs index 246e313b9a..eb4991fec3 100644 --- a/src/Umbraco.Web.Common/Mvc/UmbracoMvcConfigureOptions.cs +++ b/src/Umbraco.Web.Common/Mvc/UmbracoMvcConfigureOptions.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Umbraco.Cms.Web.Common.Filters; using Umbraco.Cms.Web.Common.ModelBinders; +using Umbraco.Cms.Web.Common.Validators; namespace Umbraco.Cms.Web.Common.Mvc; @@ -18,6 +19,8 @@ public class UmbracoMvcConfigureOptions : IConfigureOptions public void Configure(MvcOptions options) { options.ModelBinderProviders.Insert(0, new ContentModelBinderProvider()); + options.ModelValidatorProviders.Insert(0, new BypassRenderingModelValidatorProvider()); + options.ModelMetadataDetailsProviders.Add(new BypassRenderingModelValidationMetadataProvider()); options.Filters.Insert(0, new EnsurePartialViewMacroViewContextFilterAttribute()); } } diff --git a/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs b/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs index 44fa64b274..4abbb21cb3 100644 --- a/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs +++ b/src/Umbraco.Web.Common/Routing/RoutableDocumentFilter.cs @@ -70,7 +70,7 @@ public sealed class RoutableDocumentFilter : IRoutableDocumentFilter return maybeDoc; } - private void EndpointsChanged(object value) + private void EndpointsChanged(object? value) { lock (_routeLocker) { diff --git a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs index 362910e7e4..b06f8d0688 100644 --- a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs +++ b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeRuntimeMinifier.cs @@ -157,14 +157,6 @@ public class SmidgeRuntimeMinifier : IRuntimeMinifier } } - /// - [Obsolete("Invalidation is handled automatically. Scheduled for removal V11.")] - public void Reset() - { - var version = DateTime.UtcNow.Ticks.ToString(); - _configManipulator.SaveConfigValue(Core.Constants.Configuration.ConfigRuntimeMinificationVersion, version); - } - private BundleEnvironmentOptions ConfigureBundleEnvironmentOptions(BundlingOptions bundleOptions) { var bundleEnvironmentOptions = new BundleEnvironmentOptions(); diff --git a/src/Umbraco.Web.Common/Security/BackOfficeUserManager.cs b/src/Umbraco.Web.Common/Security/BackOfficeUserManager.cs index 09793081cf..352136504e 100644 --- a/src/Umbraco.Web.Common/Security/BackOfficeUserManager.cs +++ b/src/Umbraco.Web.Common/Security/BackOfficeUserManager.cs @@ -90,7 +90,7 @@ public class BackOfficeUserManager : UmbracoUserManager ChangePasswordWithResetAsync(string userId, string token, string? newPassword) + public override async Task ChangePasswordWithResetAsync(string userId, string token, string newPassword) { IdentityResult result = await base.ChangePasswordWithResetAsync(userId, token, newPassword); if (result.Succeeded) @@ -101,7 +101,7 @@ public class BackOfficeUserManager : UmbracoUserManager ChangePasswordAsync(BackOfficeIdentityUser user, string? currentPassword, string? newPassword) + public override async Task ChangePasswordAsync(BackOfficeIdentityUser user, string currentPassword, string newPassword) { IdentityResult result = await base.ChangePasswordAsync(user, currentPassword, newPassword); if (result.Succeeded) diff --git a/src/Umbraco.Web.Common/Security/ConfigureIISServerOptions.cs b/src/Umbraco.Web.Common/Security/ConfigureIISServerOptions.cs deleted file mode 100644 index fe29d86f51..0000000000 --- a/src/Umbraco.Web.Common/Security/ConfigureIISServerOptions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Options; -using Umbraco.Cms.Core.Configuration.Models; - -namespace Umbraco.Cms.Web.Common.Security; - -[Obsolete( - "This class is obsolete, as this does not configure your Maximum request length, see https://our.umbraco.com/documentation/Reference/V9-Config/MaximumUploadSizeSettings/ for information about configuring maximum request length")] -public class ConfigureIISServerOptions : IConfigureOptions -{ - private readonly IOptions _runtimeSettings; - - public ConfigureIISServerOptions(IOptions runtimeSettings) => - _runtimeSettings = runtimeSettings; - - public void Configure(IISServerOptions options) => - - // convert from KB to bytes - options.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue - ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 - : uint.MaxValue; // ~4GB is the max supported value for IIS and IIS express. -} diff --git a/src/Umbraco.Web.Common/Security/ConfigureMemberCookieOptions.cs b/src/Umbraco.Web.Common/Security/ConfigureMemberCookieOptions.cs index 1e0960fbc7..5bf7a98749 100644 --- a/src/Umbraco.Web.Common/Security/ConfigureMemberCookieOptions.cs +++ b/src/Umbraco.Web.Common/Security/ConfigureMemberCookieOptions.cs @@ -18,7 +18,7 @@ public sealed class ConfigureMemberCookieOptions : IConfigureNamedOptions { - ClaimsIdentity newIdentity = refreshingPrincipal.NewPrincipal.Identities.First(); - ClaimsIdentity currentIdentity = refreshingPrincipal.CurrentPrincipal.Identities.First(); + ClaimsIdentity? newIdentity = refreshingPrincipal.NewPrincipal?.Identities.First(); + ClaimsIdentity? currentIdentity = refreshingPrincipal.CurrentPrincipal?.Identities.First(); - // Since this is refreshing an existing principal, we want to merge all claims. - newIdentity.MergeAllClaims(currentIdentity); + if (currentIdentity is not null) + { + // Since this is refreshing an existing principal, we want to merge all claims. + newIdentity?.MergeAllClaims(currentIdentity); + } return Task.CompletedTask; }; diff --git a/src/Umbraco.Web.Common/Security/IBackOfficeSignInManager.cs b/src/Umbraco.Web.Common/Security/IBackOfficeSignInManager.cs index 8e674c8b9f..f76912743b 100644 --- a/src/Umbraco.Web.Common/Security/IBackOfficeSignInManager.cs +++ b/src/Umbraco.Web.Common/Security/IBackOfficeSignInManager.cs @@ -19,7 +19,7 @@ public interface IBackOfficeSignInManager Task GetExternalLoginInfoAsync(string? expectedXsrf = null); - Task GetTwoFactorAuthenticationUserAsync(); + Task GetTwoFactorAuthenticationUserAsync(); Task PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure); @@ -29,7 +29,7 @@ public interface IBackOfficeSignInManager Task CreateUserPrincipalAsync(BackOfficeIdentityUser user); - Task TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient); + Task TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient); Task UpdateExternalAuthenticationTokensAsync(ExternalLoginInfo externalLogin); } diff --git a/src/Umbraco.Web.Common/Security/IMemberSignInManager.cs b/src/Umbraco.Web.Common/Security/IMemberSignInManager.cs index a5a444bd06..27d034930d 100644 --- a/src/Umbraco.Web.Common/Security/IMemberSignInManager.cs +++ b/src/Umbraco.Web.Common/Security/IMemberSignInManager.cs @@ -21,7 +21,7 @@ public interface IMemberSignInManager Task ExternalLoginSignInAsync(ExternalLoginInfo loginInfo, bool isPersistent, bool bypassTwoFactor = false); - Task GetTwoFactorAuthenticationUserAsync(); + Task GetTwoFactorAuthenticationUserAsync(); - Task TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient); + Task TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient); } diff --git a/src/Umbraco.Web.Common/Security/MemberClaimsPrincipalFactory.cs b/src/Umbraco.Web.Common/Security/MemberClaimsPrincipalFactory.cs index dfc860e467..2af8274b39 100644 --- a/src/Umbraco.Web.Common/Security/MemberClaimsPrincipalFactory.cs +++ b/src/Umbraco.Web.Common/Security/MemberClaimsPrincipalFactory.cs @@ -42,8 +42,9 @@ public class MemberClaimsPrincipalFactory : UserClaimsPrincipalFactory memberIdentity.HasClaim(claim.ClaimType, claim.ClaimValue) is false) - .Select(x => new Claim(x.ClaimType, x.ClaimValue))) + .Where(claim => claim.ClaimType is not null && claim.ClaimValue is not null) + .Where(claim => memberIdentity.HasClaim(claim.ClaimType!, claim.ClaimValue!) is false) + .Select(x => new Claim(x.ClaimType!, x.ClaimValue!))) { memberIdentity.AddClaim(claim); } diff --git a/src/Umbraco.Web.Common/Security/MemberManager.cs b/src/Umbraco.Web.Common/Security/MemberManager.cs index 19be3de489..c59f0bd86e 100644 --- a/src/Umbraco.Web.Common/Security/MemberManager.cs +++ b/src/Umbraco.Web.Common/Security/MemberManager.cs @@ -188,7 +188,7 @@ public class MemberManager : UmbracoUserManager HasAccessAsync(string path) { MemberIdentityUser? currentMember = await GetCurrentMemberAsync(); - if (currentMember == null || !currentMember.IsApproved || currentMember.IsLockedOut) + if (currentMember?.UserName is null || !currentMember.IsApproved || currentMember.IsLockedOut) { return false; } @@ -220,7 +220,7 @@ public class MemberManager : UmbracoUserManager(); MemberIdentityUser? currentMember = await GetCurrentMemberAsync(); - if (currentMember == null || !currentMember.IsApproved || currentMember.IsLockedOut) + if (currentMember?.UserName is null || !currentMember.IsApproved || currentMember.IsLockedOut) { return result; } diff --git a/src/Umbraco.Web.Common/Security/MemberSignInManager.cs b/src/Umbraco.Web.Common/Security/MemberSignInManager.cs index a624129bab..393d05e9a0 100644 --- a/src/Umbraco.Web.Common/Security/MemberSignInManager.cs +++ b/src/Umbraco.Web.Common/Security/MemberSignInManager.cs @@ -159,8 +159,8 @@ public class MemberSignInManager : UmbracoSignInManager, IMe } public override AuthenticationProperties ConfigureExternalAuthenticationProperties( - string provider, - string redirectUrl, + string? provider, + string? redirectUrl, string? userId = null) { // borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs @@ -213,7 +213,7 @@ public class MemberSignInManager : UmbracoSignInManager, IMe } // Now we need to perform the auto-link, so first we need to lookup/create a user with the email address - MemberIdentityUser? autoLinkUser = await UserManager.FindByEmailAsync(email); + MemberIdentityUser? autoLinkUser = await UserManager.FindByEmailAsync(email!); if (autoLinkUser != null) { try @@ -244,7 +244,7 @@ public class MemberSignInManager : UmbracoSignInManager, IMe throw new InvalidOperationException("The Name value cannot be null"); } - autoLinkUser = MemberIdentityUser.CreateNew(email, email, autoLinkOptions.DefaultMemberTypeAlias, autoLinkOptions.DefaultIsApproved, name); + autoLinkUser = MemberIdentityUser.CreateNew(email!, email!, autoLinkOptions.DefaultMemberTypeAlias, autoLinkOptions.DefaultIsApproved, name); foreach (var userGroup in autoLinkOptions.DefaultMemberGroups) { diff --git a/src/Umbraco.Web.Common/Security/PublicAccessChecker.cs b/src/Umbraco.Web.Common/Security/PublicAccessChecker.cs index b8b662ef2b..9777f56d7d 100644 --- a/src/Umbraco.Web.Common/Security/PublicAccessChecker.cs +++ b/src/Umbraco.Web.Common/Security/PublicAccessChecker.cs @@ -47,7 +47,7 @@ public class PublicAccessChecker : IPublicAccessChecker return PublicAccessStatus.LockedOut; } - if (!_publicAccessService.HasAccess(publishedContentId, _contentService, username, userRoles)) + if (!_publicAccessService.HasAccess(publishedContentId, _contentService, username!, userRoles)) { return PublicAccessStatus.AccessDenied; } diff --git a/src/Umbraco.Web.Common/Security/UmbracoSignInManager.cs b/src/Umbraco.Web.Common/Security/UmbracoSignInManager.cs index 63defed2de..052a3ae631 100644 --- a/src/Umbraco.Web.Common/Security/UmbracoSignInManager.cs +++ b/src/Umbraco.Web.Common/Security/UmbracoSignInManager.cs @@ -86,7 +86,7 @@ public abstract class UmbracoSignInManager : SignInManager var providerKey = auth.Principal.FindFirstValue(ClaimTypes.NameIdentifier); var provider = items[UmbracoSignInMgrLoginProviderKey]; - if (providerKey == null || provider == null) + if (providerKey is null || provider is null) { return null; } @@ -102,14 +102,14 @@ public abstract class UmbracoSignInManager : SignInManager } /// - public override async Task GetTwoFactorAuthenticationUserAsync() + public override async Task GetTwoFactorAuthenticationUserAsync() { // borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs // replaced in order to use a custom auth type TwoFactorAuthenticationInfo? info = await RetrieveTwoFactorInfoAsync(); - if (info == null) + if (info?.UserId is null) { - return null!; + return null; } return await UserManager.FindByIdAsync(info.UserId); @@ -142,7 +142,7 @@ public abstract class UmbracoSignInManager : SignInManager } /// - public override async Task TwoFactorSignInAsync(string? provider, string? code, bool isPersistent, bool rememberClient) + public override async Task TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberClient) { // borrowed from https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs#L552 // replaced in order to use a custom auth type and to implement logging/events diff --git a/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj b/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj index bda3be4ebc..338c9d2c5c 100644 --- a/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj +++ b/src/Umbraco.Web.Common/Umbraco.Web.Common.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Library Umbraco.Cms.Web.Common Umbraco.Cms.Web.Common @@ -9,7 +9,7 @@ Contains the Web assembly needed to run Umbraco Cms. This package only contains the assembly, and can be used for package development. Use the template in the Umbraco.Templates package to setup Umbraco - net6.0 + net7.0 Library Umbraco.Cms.Web.Common Umbraco.Cms.Web.Common @@ -35,8 +35,6 @@ - - diff --git a/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidationMetadataProvider.cs b/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidationMetadataProvider.cs new file mode 100644 index 0000000000..94f0dea502 --- /dev/null +++ b/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidationMetadataProvider.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Web.Common.Validators; + +/// +/// Ensures we bypass object graph validation for rendering models. +/// +internal class BypassRenderingModelValidationMetadataProvider : IValidationMetadataProvider +{ + public void CreateValidationMetadata(ValidationMetadataProviderContext context) + { + if (context.Key.ModelType.IsRenderingModel()) + { + context.ValidationMetadata.ValidateChildren = false; + } + } +} diff --git a/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidatorProvider.cs b/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidatorProvider.cs new file mode 100644 index 0000000000..ab52483180 --- /dev/null +++ b/src/Umbraco.Web.Common/Validators/BypassRenderingModelValidatorProvider.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Web.Common.Validators; + +/// +/// Ensures we bypass property validation for rendering models. +/// +internal class BypassRenderingModelValidatorProvider : IModelValidatorProvider +{ + public void CreateValidators(ModelValidatorProviderContext context) + { + if (context.ModelMetadata.ModelType.IsRenderingModel()) + { + context.Results.Clear(); + context.Results.Add(new ValidatorItem + { + Validator = null, + IsReusable = true + }); + } + } +} + + diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 2e9cca84fc..ddec00129b 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -1,18 +1,26 @@ - net6.0 + net7.0 Umbraco.Cms.Web.UI false + + + + bin/Release/Umbraco.Web.UI.xml + + + + true + + - - @@ -54,6 +62,8 @@ + + @@ -67,4 +77,5 @@ + diff --git a/src/Umbraco.Web.Website/Controllers/UmbExternalLoginController.cs b/src/Umbraco.Web.Website/Controllers/UmbExternalLoginController.cs index 1ea68f40aa..2cbda678de 100644 --- a/src/Umbraco.Web.Website/Controllers/UmbExternalLoginController.cs +++ b/src/Umbraco.Web.Website/Controllers/UmbExternalLoginController.cs @@ -111,7 +111,7 @@ public class UmbExternalLoginController : SurfaceController if (result == SignInResult.TwoFactorRequired) { - MemberIdentityUser attemptedUser = + MemberIdentityUser? attemptedUser = await _memberManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey); if (attemptedUser == null!) { @@ -218,7 +218,7 @@ public class UmbExternalLoginController : SurfaceController [HttpGet] public async Task ExternalLinkLoginCallback(string returnUrl) { - MemberIdentityUser user = await _memberManager.GetUserAsync(User); + MemberIdentityUser? user = await _memberManager.GetUserAsync(User); string? loginProvider = null; var errors = new List(); if (user == null!) @@ -272,10 +272,20 @@ public class UmbExternalLoginController : SurfaceController returnUrl = Request.GetEncodedPathAndQuery(); } - MemberIdentityUser user = await _memberManager.FindByIdAsync(User.Identity?.GetUserId()); + var userId = User.Identity?.GetUserId(); + if (userId is null) + { + return CurrentUmbracoPage(); + } + + MemberIdentityUser? user = await _memberManager.FindByIdAsync(userId); + + if (user is null) + { + return CurrentUmbracoPage(); + } IdentityResult result = await _memberManager.RemoveLoginAsync(user, provider, providerKey); - if (result.Succeeded) { await _memberSignInManager.SignInAsync(user, false); @@ -283,6 +293,7 @@ public class UmbExternalLoginController : SurfaceController } AddModelErrors(result); + return CurrentUmbracoPage(); } } diff --git a/src/Umbraco.Web.Website/Controllers/UmbLoginController.cs b/src/Umbraco.Web.Website/Controllers/UmbLoginController.cs index cd9bc15e35..c195b52409 100644 --- a/src/Umbraco.Web.Website/Controllers/UmbLoginController.cs +++ b/src/Umbraco.Web.Website/Controllers/UmbLoginController.cs @@ -41,28 +41,6 @@ public class UmbLoginController : SurfaceController _twoFactorLoginService = twoFactorLoginService; } - [Obsolete("Use ctor with all params")] - public UmbLoginController( - IUmbracoContextAccessor umbracoContextAccessor, - IUmbracoDatabaseFactory databaseFactory, - ServiceContext services, - AppCaches appCaches, - IProfilingLogger profilingLogger, - IPublishedUrlProvider publishedUrlProvider, - IMemberSignInManager signInManager) - : this( - umbracoContextAccessor, - databaseFactory, - services, - appCaches, - profilingLogger, - publishedUrlProvider, - signInManager, - StaticServiceProvider.Instance.GetRequiredService(), - StaticServiceProvider.Instance.GetRequiredService()) - { - } - [HttpPost] [ValidateAntiForgeryToken] [ValidateUmbracoFormRouteString] @@ -103,7 +81,7 @@ public class UmbLoginController : SurfaceController if (result.RequiresTwoFactor) { - MemberIdentityUser attemptedUser = await _memberManager.FindByNameAsync(model.Username); + MemberIdentityUser? attemptedUser = await _memberManager.FindByNameAsync(model.Username); if (attemptedUser == null!) { return new ValidationErrorResult( diff --git a/src/Umbraco.Web.Website/Models/ProfileModelBuilder.cs b/src/Umbraco.Web.Website/Models/ProfileModelBuilder.cs index 982fb127cd..70f034fc79 100644 --- a/src/Umbraco.Web.Website/Models/ProfileModelBuilder.cs +++ b/src/Umbraco.Web.Website/Models/ProfileModelBuilder.cs @@ -51,7 +51,7 @@ public class ProfileModelBuilder : MemberModelBuilderBase ? null : await memberManager.GetUserAsync(_httpContextAccessor.HttpContext.User); - if (member == null) + if (member?.Email is null || member?.UserName is null) { return null; } diff --git a/src/Umbraco.Web.Website/Security/MemberAuthenticationBuilder.cs b/src/Umbraco.Web.Website/Security/MemberAuthenticationBuilder.cs index 0029e0b80a..50e6f80b78 100644 --- a/src/Umbraco.Web.Website/Security/MemberAuthenticationBuilder.cs +++ b/src/Umbraco.Web.Website/Security/MemberAuthenticationBuilder.cs @@ -62,9 +62,9 @@ public class MemberAuthenticationBuilder : AuthenticationBuilder private class EnsureMemberScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { - public void PostConfigure(string name, TOptions options) + public void PostConfigure(string? name, TOptions options) { - if (!name.StartsWith(Constants.Security.MemberExternalAuthenticationTypePrefix)) + if (name is null || !name.StartsWith(Constants.Security.MemberExternalAuthenticationTypePrefix)) { return; } diff --git a/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj b/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj index 176564eaf8..94f3bfa479 100644 --- a/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj +++ b/src/Umbraco.Web.Website/Umbraco.Web.Website.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Library Umbraco.Cms.Web.Website Umbraco.Cms.Web.Website diff --git a/templates/Umbraco.Templates.csproj b/templates/Umbraco.Templates.csproj index d01e811cde..eef2c96ec9 100644 --- a/templates/Umbraco.Templates.csproj +++ b/templates/Umbraco.Templates.csproj @@ -1,6 +1,6 @@ - net6.0 + net7.0 Template false . diff --git a/templates/UmbracoPackage/UmbracoPackage.csproj b/templates/UmbracoPackage/UmbracoPackage.csproj index cdab2646e0..92c1e78d82 100644 --- a/templates/UmbracoPackage/UmbracoPackage.csproj +++ b/templates/UmbracoPackage/UmbracoPackage.csproj @@ -1,6 +1,6 @@  - net6.0 + net7.0 . UmbracoPackage UmbracoPackage diff --git a/templates/UmbracoProject/UmbracoProject.csproj b/templates/UmbracoProject/UmbracoProject.csproj index 2880b754e6..c2234b0f1e 100644 --- a/templates/UmbracoProject/UmbracoProject.csproj +++ b/templates/UmbracoProject/UmbracoProject.csproj @@ -1,6 +1,6 @@ - net6.0 + net7.0 enable enable Umbraco.Cms.Web.UI diff --git a/tests/Umbraco.TestData/Umbraco.TestData.csproj b/tests/Umbraco.TestData/Umbraco.TestData.csproj index b5b2c5c99f..b2c9fa7236 100644 --- a/tests/Umbraco.TestData/Umbraco.TestData.csproj +++ b/tests/Umbraco.TestData/Umbraco.TestData.csproj @@ -3,7 +3,7 @@ false Umbraco.TestData - net6.0 + net7.0 diff --git a/tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker b/tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker index 5ae033d6d3..2efbb9a2da 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker +++ b/tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker @@ -2,7 +2,7 @@ ## Build ############################################ -FROM mcr.microsoft.com/dotnet/sdk:6.0.300 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:7.0 AS build WORKDIR /nupkg COPY nupkg . @@ -17,7 +17,7 @@ RUN dotnet publish --no-restore --configuration Release -o /dist ## Run ############################################ -FROM mcr.microsoft.com/dotnet/aspnet:6.0.5 AS run +FROM mcr.microsoft.com/dotnet/nightly/aspnet:7.0 AS run WORKDIR /cypress COPY --from=build dist . diff --git a/tests/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj b/tests/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj index b8e9130d56..c0b1d2d0e4 100644 --- a/tests/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj +++ b/tests/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj @@ -1,6 +1,6 @@ - net6.0 + net7.0 Exe false false @@ -26,7 +26,7 @@ 0.13.2 - 6.0.0 + 7.0.0-preview.7.22375.6 4.18.1 diff --git a/tests/Umbraco.Tests.Common/Testing/TestOptionAttributeBase.cs b/tests/Umbraco.Tests.Common/Testing/TestOptionAttributeBase.cs index 0134365ef9..e7e94ee47a 100644 --- a/tests/Umbraco.Tests.Common/Testing/TestOptionAttributeBase.cs +++ b/tests/Umbraco.Tests.Common/Testing/TestOptionAttributeBase.cs @@ -13,9 +13,6 @@ namespace Umbraco.Cms.Tests.Common.Testing; public abstract class TestOptionAttributeBase : Attribute { - [Obsolete("This is not used anymore - Test classes are found using nunit helpers")] - public static readonly List ScanAssemblies = new(); - public static TOptions GetTestOptions(MethodInfo method) where TOptions : TestOptionAttributeBase, new() { diff --git a/tests/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj b/tests/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj index e24424631f..4fee3d2091 100644 --- a/tests/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj +++ b/tests/Umbraco.Tests.Common/Umbraco.Tests.Common.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Tests.Common Umbraco.Cms.Tests Umbraco CMS Test Tools diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs index c2fd4a1ab4..148758f7ca 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs @@ -89,8 +89,8 @@ public class RuntimeStateTests : UmbracoIntegrationTest MediaUrlGeneratorCollection mediaUrlGenerators, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, - IMigrationContext context) - : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context) + IMigrationContext context, IOptions options) + : base(packagingService, mediaService, mediaFileManager, mediaUrlGenerators, shortStringHelper, contentTypeBaseServiceProvider, context, options) { } diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs index ff7b7a7275..40bdd6cf67 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs @@ -786,7 +786,7 @@ public class PackageDataInstallationTests : UmbracoIntegrationTestWithContent // Act var contentTypes = PackageDataInstallation .ImportDocumentType(withoutCleanupPolicy, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() => @@ -805,7 +805,7 @@ public class PackageDataInstallationTests : UmbracoIntegrationTestWithContent // Act var contentTypes = PackageDataInstallation .ImportDocumentType(docTypeElement, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() => @@ -827,11 +827,11 @@ public class PackageDataInstallationTests : UmbracoIntegrationTestWithContent // Act var contentTypes = PackageDataInstallation .ImportDocumentType(withCleanupPolicy, 0) - .OfType(); + .OfType(); var contentTypesUpdated = PackageDataInstallation .ImportDocumentType(withoutCleanupPolicy, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() => diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MacroServiceTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MacroServiceTests.cs index da6f40d9ac..9353644daf 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MacroServiceTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MacroServiceTests.cs @@ -22,6 +22,9 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services; [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] public class MacroServiceTests : UmbracoIntegrationTest { + + private IMacroService MacroService => GetRequiredService(); + [SetUp] public void SetupTest() { @@ -38,10 +41,6 @@ public class MacroServiceTests : UmbracoIntegrationTest } } - [Obsolete( - "After merging IMacroWithAliasService interface with IMacroService in Umbraco 11, this should go back to just being GetRequiredService()")] - private IMacroWithAliasService MacroService => GetRequiredService() as IMacroWithAliasService; - [Test] public void Can_Get_By_Alias() { diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RelationServiceTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RelationServiceTests.cs index 04c94d7268..a7f79dec64 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RelationServiceTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RelationServiceTests.cs @@ -121,7 +121,7 @@ public class RelationServiceTests : UmbracoIntegrationTest { var rs = RelationService; IRelationType rt = new RelationType("Test", "repeatedEventOccurence", false, Constants.ObjectTypes.Document, - Constants.ObjectTypes.Media); + Constants.ObjectTypes.Media, false); Assert.DoesNotThrow(() => rs.Save(rt)); @@ -139,7 +139,7 @@ public class RelationServiceTests : UmbracoIntegrationTest public void Create_Relation_Type_Without_Object_Types() { var rs = RelationService; - IRelationType rt = new RelationType("repeatedEventOccurence", "repeatedEventOccurence", false, null, null); + IRelationType rt = new RelationType("repeatedEventOccurence", "repeatedEventOccurence", false, null, null, false); Assert.DoesNotThrow(() => rs.Save(rt)); @@ -216,7 +216,7 @@ public class RelationServiceTests : UmbracoIntegrationTest private IRelation CreateAndSaveRelation(string name, string alias) { var rs = RelationService; - var rt = new RelationType(name, alias, false, null, null); + var rt = new RelationType(name, alias, false, null, null, false); rs.Save(rt); var ct = ContentTypeBuilder.CreateBasicContentType(); @@ -245,7 +245,7 @@ public class RelationServiceTests : UmbracoIntegrationTest { var rs = RelationService; var rtName = Guid.NewGuid().ToString(); - var rt = new RelationType(rtName, rtName, false, null, null); + var rt = new RelationType(rtName, rtName, false, null, null, false); rs.Save(rt); var ct = ContentTypeBuilder.CreateBasicContentType(); diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj b/tests/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj index 1cbbad630d..20173ac46d 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj +++ b/tests/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 Umbraco.Cms.Tests.Integration Umbraco.Cms.Tests.Integration Umbraco CMS Integration Tests @@ -88,7 +88,6 @@ - diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs index 51435a2b19..dd5b32031f 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/EnumExtensionsTests.cs @@ -29,25 +29,6 @@ public class EnumExtensionsTests } } - [Obsolete] - [TestCase(TreeUse.Dialog, TreeUse.Dialog, true)] - [TestCase(TreeUse.Dialog, TreeUse.Main, false)] - [TestCase(TreeUse.Dialog | TreeUse.Main, TreeUse.Dialog, true)] - [TestCase(TreeUse.Dialog, TreeUse.Dialog | TreeUse.Main, false)] - public void HasFlagAllTest(TreeUse value, TreeUse test, bool expected) - { - // The HasFlagAll() extension method determines whether - // all bits from are set (other bits can be set too). - if (expected) - { - Assert.IsTrue(value.HasFlagAll(test)); - } - else - { - Assert.IsFalse(value.HasFlagAll(test)); - } - } - [TestCase(TreeUse.Dialog, TreeUse.Dialog, true)] [TestCase(TreeUse.Dialog, TreeUse.Main, false)] [TestCase(TreeUse.Dialog | TreeUse.Main, TreeUse.Dialog, true)] diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ModelTypeTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ModelTypeTests.cs index 1176b7f571..d850d00d3d 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ModelTypeTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ModelTypeTests.cs @@ -46,7 +46,7 @@ public class ModelTypeTests // Note the inner assembly qualified name Assert.AreEqual( - "System.Collections.Generic.IEnumerable`1[[System.Int32[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]", + "System.Collections.Generic.IEnumerable`1[[System.Int32[], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]", typeof(IEnumerable<>).MakeGenericType(type.MakeArrayType()).FullName); } diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/ShortStringHelper/DefaultShortStringHelperTestsWithoutSetup.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/ShortStringHelper/DefaultShortStringHelperTestsWithoutSetup.cs index a9748a5484..9d7d95554a 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/ShortStringHelper/DefaultShortStringHelperTestsWithoutSetup.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/ShortStringHelper/DefaultShortStringHelperTestsWithoutSetup.cs @@ -18,7 +18,7 @@ public class DefaultShortStringHelperTestsWithoutSetup { var requestHandlerSettings = new RequestHandlerSettings { - CharCollection = Array.Empty(), + UserDefinedCharCollection = Array.Empty(), EnableDefaultCharReplacements = false, ConvertUrlsToAscii = "false", }; @@ -47,7 +47,7 @@ public class DefaultShortStringHelperTestsWithoutSetup { var requestHandlerSettings = new RequestHandlerSettings { - CharCollection = Array.Empty(), + UserDefinedCharCollection = Array.Empty(), EnableDefaultCharReplacements = false, ConvertUrlsToAscii = "false", }; @@ -383,7 +383,7 @@ public class DefaultShortStringHelperTestsWithoutSetup { var requestHandlerSettings = new RequestHandlerSettings { - CharCollection = Array.Empty(), + UserDefinedCharCollection = Array.Empty(), EnableDefaultCharReplacements = false, ConvertUrlsToAscii = "false", }; diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Security/MemberPasswordHasherTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Security/MemberPasswordHasherTests.cs index 8e8b39bb42..9d26be6ab6 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Security/MemberPasswordHasherTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Security/MemberPasswordHasherTests.cs @@ -15,10 +15,11 @@ public class MemberPasswordHasherTests [Test] [TestCase( "Password123!", - "AQAAAAEAACcQAAAAEGF/tTVoL6ef3bQPZFYfbgKFu1CDQIAMgyY1N4EDt9jqdG/hsOX93X1U6LNvlIQ3mw==", + "AQAAAAIAAYagAAAAEJBorDjt+UEvw55UJVsbgAS6T2IGao+2XpCBbO3EKZoAMzoN+CNOpPdu1c0qrFcJVw==", null, ExpectedResult = PasswordVerificationResult.Success, Description = "AspNetCoreIdentityPasswordHash: Correct password")] + [TestCase("Password123!", "AQAAAAEAACcQAAAAEGF/tTVoL6ef3bQPZFYfbgKFu1CDQIAMgyY1N4EDt9jqdG/hsOX93X1U6LNvlIQ3mw==", null, - ExpectedResult = PasswordVerificationResult.Success, - Description = "AspNetCoreIdentityPasswordHash: Correct password")] + ExpectedResult = PasswordVerificationResult.SuccessRehashNeeded, + Description = "GivenALegacyAspNetCoreIdentityPasswordHash: Correct password")] [TestCase( "wrongPassword", "AQAAAAEAACcQAAAAEGF/tTVoL6ef3bQPZFYfbgKFu1CDQIAMgyY1N4EDt9jqdG/hsOX93X1U6LNvlIQ3mw==", diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj b/tests/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj index 3a92ff5777..e409f97fe1 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 Umbraco.Cms.Tests.UnitTests false true @@ -27,8 +27,8 @@ - - + + diff --git a/version.json b/version.json index 1b7f726e3f..157ba1125f 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "10.3.0-rc", + "version": "11.0.0", "assemblyVersion": { "precision": "Build" // optional. Use when you want a more precise assembly version than the default major.minor. },